Skip to content

Instantly share code, notes, and snippets.

{
"selector": "source.php",
"cmd": ["php", "-l", "$file"],
"variants": [
{
"name": "Run",
"cmd": ["php", "$file"]
},
@leotop
leotop / grab_instagram_users_photos.py
Created March 16, 2016 08:52 — forked from felinx/grab_instagram_users_photos.py
Grab instagram user's photos through client API
# -*- coding: utf-8 -*-
#
# Copyright(c) 2015 http://feilong.me
#
# @author: Felinx Lee <felinx.lee@gmail.com>
#
from tornado.httpclient import HTTPClient, HTTPRequest
from tornado import escape
import hashlib
@leotop
leotop / zipdb.py
Created March 16, 2016 08:53 — forked from felinx/zipdb.py
Use a zipfile store a dict like k-v database
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# zipdb.py
# Use a zipfile store a dict like k-v database.
# Known bug: duplicate key(filenames) allowed
#
# Copyright 2012 mayli <mayli.he@gmail.com>
#
@leotop
leotop / gist:8bbc0cca17efbbd3b524017a14524ffb
Created May 22, 2016 20:52 — forked from benjamingeiger/gist:3627064
Cartesian product of lists in Python.
def cartesian (lists):
if lists == []: return [()]
return [x + (y,) for x in cartesian(lists[:-1]) for y in lists[-1]]
print cartesian([[1, 2, 3], [2, 4, 6], [3, 6, 9]])
@leotop
leotop / sorted.py
Created May 22, 2016 21:39 — forked from benjamingeiger/sorted.py
Python script to find the longest words with letters in reverse alphabetical order.
# Remove non-alphabetic characters (hyphens, etc) from the word.
def strip_non_alpha(word):
return "".join([x for x in list(word.lower()) if (x >= 'a' and x <= 'z')])
# Sort the letters in the word (in reverse).
def sort_letters(word):
letters = sorted(list(word))
letters.reverse()
return "".join(letters)
@leotop
leotop / gist:e005bbce325c1aecb4ad8e10c25e721c
Created May 22, 2016 21:39 — forked from benjamingeiger/gist:3224160
Grid search implementation.
def grid_search(features, results):
gamma_values = [(2 ** n) for n in range(-15, 4)]
cost_values = [(2 ** n) for n in range(-5, 16)]
params_values = [(gamma, cost) for gamma in gamma_values
for cost in cost_values]
best_auc = 0
best_gamma = None
best_cost = None
// Cartesian product of arrays
// @takes N arrays -- arguments *must* be arrays
// @returns an array of X arrays of N elements, X being the product of the input arrays' lengths.
function cartesianProduct(...arrays) {
function _inner(...args) {
if (arguments.length > 1) {
let arr2 = args.pop(); // arr of arrs of elems
let arr1 = args.pop(); // arr of elems
return _inner(...args,
@leotop
leotop / cartesian-product.js
Created May 22, 2016 21:45 — forked from ijy/cartesian-product.js
Underscore.js implementation of Cartesian Product (without any mutable variable). @see: http://stackoverflow.com/questions/12303989/cartesian-product-of-multiple-arrays-in-javascript
function cartesianProductOf() {
return _.reduce(arguments, function(a, b) {
return _.flatten(_.map(a, function(x) {
return _.map(b, function(y) {
return x.concat([y]);
});
}), true);
}, [ [] ]);
};
@leotop
leotop / box-shadow.html
Created June 15, 2016 23:40 — forked from ocean90/box-shadow.html
CSS3 Box Shadow, only top/right/bottom/left and all
<!DOCTYPE html>
<html>
<head>
<title>Box Shadow</title>
<style>
.box {
height: 150px;
width: 300px;
margin: 20px;
<?xml version="1.0" encoding="UTF-8" ?>
<Data>
<Series>
<id>83462</id>
<Actors>|Nathan Fillion|Stana Katic|Molly C. Quinn|Jon Huertas|Seamus Dever|Tamala Jones|Susan Sullivan|Ruben Santiago-Hudson|Monet Mazur|</Actors>
<Airs_DayOfWeek>Monday</Airs_DayOfWeek>
<Airs_Time>10:00 PM</Airs_Time>
<ContentRating>TV-PG</ContentRating>
<FirstAired>2009-03-09</FirstAired>
<Genre>|Drama|</Genre>