Skip to content

Instantly share code, notes, and snippets.

View prat0318's full-sized avatar
💭
Ubering on.

Prateek Agarwal prat0318

💭
Ubering on.
View GitHub Profile
@prat0318
prat0318 / new_machine.md
Last active August 5, 2019 20:41
New machine setup

update

sudo apt-get update

install vim / git / zsh

sudo apt-get install -y git vim zsh

change shell to zsh

chsh -s $(which zsh)

to know your external IP

apiVersion: v1
data:
default.conf: |-
client_body_buffer_size 10M;
client_max_body_size 10M;
lua_shared_dict prometheus_metrics 50M;
lua_package_path "/opt/nginx-lua-prometheus/?.lua";
init_by_lua '
prometheus = require("prometheus").init("prometheus_metrics")
@prat0318
prat0318 / proxy.pac
Last active September 21, 2017 17:13
function FindProxyForURL(url, host) {
return "SOCKS localhost:54311";
}
@prat0318
prat0318 / proxy.pac
Last active September 21, 2017 17:51
function FindProxyForURL(url, host) {
PROXY = "SOCKS localhost:54311"
if (shExpMatch(host,"10.129.*")) {
return PROXY;
}
// Everything else directly!
return "DIRECT";
}
@prat0318
prat0318 / gist:0c91e655fb3ea960a2c6e6b889f47053
Created June 14, 2017 05:33
Sample history to run flash photography
2 git clone https://github.com/prat0318/flash.git
3 cd flash/
4 sudo apt-get update
5 sudo apt-get install -y python-dev python-pip
6 sudo pip install -y pillow flask
7 sudo pip install pillow flask
8 ls
9 flask run
10 vi wsgi.py
11 ls
{{- range $_, $key := .Values | keys | sortAlpha -}}
{{- $value := index $.Values $key -}}
{{- if kindIs "map" $value -}}
{{- range $_, $nested_key := $value | keys | sortAlpha -}}
{{- $nested_value := index $value $nested_key -}}
{{- if kindIs "map" $nested_value -}}
{{- range $_, $nested_nested_key := $nested_value | keys | sortAlpha -}}
{{- $nested_nested_value := index $nested_value $nested_nested_key -}}
{{- if kindIs "map" $nested_nested_value -}}
{{- range $_, $nested_nested_nested_key := $nested_nested_value | keys | sortAlpha -}}
times = int(raw_input())
for i in xrange(times):
num_str = raw_input()
num = list(num_str)
old_num = list(num)
for j in xrange(len(num) - 1):
k = j + 1
if max(num[k:]) > num[j]:
k1 = k + num_str[k:].rfind(max(num[k:]))
@prat0318
prat0318 / options.zsh
Created January 14, 2015 12:23
`options` command to show all the aliases and functions offered by plugins you have installed via oh-my-zsh
function options() {
PLUGIN_PATH="$HOME/.oh-my-zsh/plugins/"
for plugin in $plugins; do
echo "\n\nPlugin: $plugin"; grep -r "^function \w*" $PLUGIN_PATH$plugin | awk '{print $2}' | sed 's/()//'| tr '\n' ', '; grep -r "^alias" $PLUGIN_PATH$plugin | awk '{print $2}' | sed 's/=.*//' | tr '\n' ', '
done
}
@prat0318
prat0318 / move1000
Created November 19, 2014 20:16
Correct Turn 1000 for without Best
Turn = 1000.
012345678901234567890123456789012345678901234567890123456789012345678901
0 r.......................................................................
1 ........................................................................
2 ........................................................................
3 ........................................................................
4 ........................................................................
5 ........r..r............................................................
6 ..........r.............................................................
7 ........................................................................
@prat0318
prat0318 / cycle_sort.py
Last active August 29, 2015 14:07
cycle sort
def cycle_sort(arr):
writes = 0
for cycle_start in xrange(len(arr)):
item = arr[cycle_start]
print "Item picked :%s index: %s [A: %s]" % (item, cycle_start, arr)
pos = cycle_start
for i in xrange(cycle_start + 1, len(arr)):
if arr[i] < item: