Skip to content

Instantly share code, notes, and snippets.

@wheatdog
wheatdog / install.sh
Created June 17, 2019 08:00
Install rclone without root
#!/usr/bin/env bash
trap_exit() {
if [[ ! -o xtrace ]]; then
rm -rf "$tmp"
fi
}
tmp=$(mktemp -dt)
def is_at_most_one_fixable_non_decreasing(num_list):
for skip_index in range(len(num_list)):
non_decreasing = True
for idx in range(1,len(num_list)):
if non_decreasing == False:
break
if idx == skip_idx:
continue
@wheatdog
wheatdog / 2
Last active April 7, 2017 13:46
ml1.1
1:
[ 9.00e+00 4.00e+00 4.00e+00 -1.00e+00 -4.00e+00 -4.00e+00 0.00e+00]
[ 4.00e+00 9.00e+00 1.00e+00 -4.00e+00 -1.60e+01 0.00e+00 -4.00e+00]
[ 4.00e+00 1.00e+00 9.00e+00 -4.00e+00 0.00e+00 -1.60e+01 -4.00e+00]
[-1.00e+00 -4.00e+00 -4.00e+00 9.00e+00 4.00e+00 4.00e+00 1.60e+01]
[-4.00e+00 -1.60e+01 0.00e+00 4.00e+00 3.60e+01 4.00e+00 4.00e+00]
[-4.00e+00 0.00e+00 -1.60e+01 4.00e+00 4.00e+00 3.60e+01 4.00e+00]
[ 0.00e+00 -4.00e+00 -4.00e+00 1.60e+01 4.00e+00 4.00e+00 3.60e+01]
2:
@wheatdog
wheatdog / firewall.sh
Created March 11, 2017 10:21
cnl-lab1
#!/bin/sh
# INIT
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
# NAT
iptables -t nat -A POSTROUTING -s192.168.100.0/24 -o eth0 -j MASQUERADE
@wheatdog
wheatdog / nfs-check.sh
Created February 25, 2017 10:46
nfs-check.sh
#!/bin/sh
stat_timeout=0.3 #seconds
for mp in $(mount -t nfs4 | awk '{print $3}'); do
timeout -s kill ${stat_timeout} stat -t "$mp" > /dev/null
if [ $? == 137 ]; then
printf 'unmount %s\n' "${mp}"
#umount -f "${mp}"
else
@wheatdog
wheatdog / gist:280461d43a3b4a4d38fa7cbc68d2bb05
Created November 24, 2016 14:53
part of sudo-write.kak
eval -save-regs %{/"|^@pf} %{
set buffer autoreload yes
prompt -password password: p %{
exec -draft \%"fy
nop %sh{
echo ${kak_reg_p} | sudo -S sh -c "printf '%s' \"${kak_reg_f}\" | tee ${kak_buffile} >/dev/null"
}
}
}
@wheatdog
wheatdog / autochdir.kak
Last active January 3, 2017 12:13
autochdir.kak
##
## autochdir.kak by wheatdog
## Automatically change server's working directory according to the current focus buffer
## To turn on this option, add `set global autochdir true` in your kakrc
##
decl bool autochdir
decl str working_folder
def -hidden \
@wheatdog
wheatdog / main.cpp
Created April 9, 2016 07:00
icg hw1
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include "controls.hpp"
#include "TRIModel.h"
# i3 config file (v4)
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
# Set mod key (Mod1=<Alt>, Mod4=<Super>)
set $mod Mod4
# set default desktop layout (default is tiling)
# workspace_layout tabbed <stacking|tabbed>
# Configure border style <normal|1pixel|pixel xx|none|pixel>
@wheatdog
wheatdog / build.bat
Last active December 27, 2015 17:42
HandmadeHero Annotation SRT transformer
@echo off
cl -nologo -FC handmade_srt_gen.cpp kernel32.lib