Skip to content

Instantly share code, notes, and snippets.

View jsam's full-sized avatar
🦁

sam jsam

🦁
View GitHub Profile
@jsam
jsam / group.py
Last active September 10, 2015 10:29
Group
from array import array
import numpy as np
import math
import sys
sys.setrecursionlimit(15000)
GRID = None
@jsam
jsam / setup-vpn.sh
Created June 16, 2015 12:17
configure vpn
#!/bin/sh
# Setup Simple PPTP VPN server for Ubuntu and Debian
# Copyright (C) 2013-2015 Viljo Viitanen <[email protected]> and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@jsam
jsam / gist:5284285871c6feb2cc3f
Created May 10, 2015 19:46
~/.config/terminator/config
[global_config]
window_state = fullscreen
title_transmit_bg_color = "#d30102"
suppress_multiple_term_dialog = True
focus = system
tab_position = bottom
[keybindings]
[profiles]
[[default]]
scrollbar_position = hidden
@jsam
jsam / gist:4ae378163d08a2c9a8b0
Created May 7, 2015 21:23
redis query queue get's filled up cause of georadius
127.0.0.1:6379> slowlog get 50
1) 1) (integer) 817005
2) (integer) 1431033515
3) (integer) 15635
4) 1) "georadius"
2) "posts"
3) "42.3345467"
4) "-7.8616236"
5) "10"
6) "km"
@jsam
jsam / README.md
Last active August 29, 2015 14:20 — forked from rantav/README.md

A few show tricks to find slow queries in mongodb

Enable profiling

First, you have to enable profiling

> db.setProfilingLevel(1)

Now let it run for a while. It collects the slow queries ( > 100ms) into a capped collections, so queries go in and if it's full, old queries go out, so don't be surprised that it's a moving target...

{
"color_scheme": "Packages/Theme - Brogrammer/brogrammer.tmTheme",
"font_face": "Monaco",
"font_options":
[
"bold"
],
"font_size": 10,
"ignored_packages":
[
In [1]: one_line="/v1/events?os=ios&bundle=com.tastykhana.iphoneapp&event=launch&network=Organic&store=itunes&idfa=2D015C54-45B6-4F92-A3FF-52943270B418&ip=223.227.74.181&time=1422890326&country=in&device_name=iPhone5%2C2&os_version=8.1&session=1&idfv=19B9CA81-FE37-460B-97AE-72CFCEE703DC&adid=15f0eaed042333af989fe2623c030fd9&iad_attribution_value=0&language=en&tracking_enabled=1&time_spent=1&environment=sandbox&timezone=UTC%2B0530"
In [2]: one_line.split("?")
Out[2]:
['/v1/events',
'os=ios&bundle=com.tastykhana.iphoneapp&event=launch&network=Organic&store=itunes&idfa=2D015C54-45B6-4F92-A3FF-52943270B418&ip=223.227.74.181&time=1422890326&country=in&device_name=iPhone5%2C2&os_version=8.1&session=1&idfv=19B9CA81-FE37-460B-97AE-72CFCEE703DC&adid=15f0eaed042333af989fe2623c030fd9&iad_attribution_value=0&language=en&tracking_enabled=1&time_spent=1&environment=sandbox&timezone=UTC%2B0530']
In [3]: values = one_line.split("?")[1]
In [4]: values
@jsam
jsam / gist:898f1c19bd2ca3013001
Last active August 29, 2015 14:14
what is the output?
var fullname = 'Samuel';
var obj = {
fullname: 'Alexandar',
prop: {
fullname: 'Alessio',
getFullname: function() {
return this.fullname;
}
}
};
@jsam
jsam / gist:efd9bca17631a506e8f8
Created January 31, 2015 14:12
what is the output?
function test() {
console.log(a);
console.log(foo());
var a = 1;
function foo() {
return 2;
}
}
@jsam
jsam / gist:8fe8caa18e616388f225
Created January 31, 2015 12:10
what it will print out?
var fullname = 'Samuel';
var obj = {
fullname: 'Alexandar',
prop: {
fullname: 'Alessio',
getFullname: function() {
return this.fullname;
}
}
};