Skip to content

Instantly share code, notes, and snippets.

function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
workout = {
buddys = "<null>";
completed = 1;
"gym_id" = "<null>";
mood = "<null>";
name = "Custom Workout";
provider = ios;
"total_workout_time" = 22;
"via_logger" = 1;
"workout_date" = 1483878574;
@dachev
dachev / wget
Created April 4, 2012 21:41
wget
blago@Blagovest-Dachevs-MacBook-Pro iOS (master) $ wget "http://d2xqg7gw3c1myh.cloudfront.net/tcvt_v002/tcvt_v002_cell200_ipad_29.ts"
--2012-04-04 16:30:51-- http://d2xqg7gw3c1myh.cloudfront.net/tcvt_v002/tcvt_v002_cell200_ipad_29.ts
Resolving d2xqg7gw3c1myh.cloudfront.net (d2xqg7gw3c1myh.cloudfront.net)... 205.251.203.119, 205.251.203.96, 205.251.203.121, ...
Connecting to d2xqg7gw3c1myh.cloudfront.net (d2xqg7gw3c1myh.cloudfront.net)|205.251.203.119|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 348368 (340K) [video/MP2T]
Saving to: `tcvt_v002_cell200_ipad_29.ts.1'
0% [ ] 0 --.-K/s in 0s
@dachev
dachev / hack.sh
Created March 31, 2012 14:20 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
"America/Adak",
"America/Anchorage",
"America/Anguilla",
"America/Antigua",
"America/Araguaina",
"America/Argentina/Buenos_Aires",
"America/Argentina/Catamarca",
"America/Argentina/Cordoba",
"America/Argentina/Jujuy",
"America/Argentina/La_Rioja",
@dachev
dachev / search.rb
Created March 2, 2012 03:49
Search
class << ActiveRecord::Base
def each(chunk_size=100)
(0..self.last.id / chunk_size).each do |offset|
self.find(:all, :limit => chunk_size, :conditions => ['id > ?', offset * chunk_size]).each do |i|
yield i
end
end
end
end
@dachev
dachev / apns.js
Created February 13, 2012 06:52
Payload
/*
* Replace device token with your own
*/
// News
{"aps":
{"badge":1,
"alert":"Breaking News",
"sound":"default"
},
@dachev
dachev / map_reduce.js
Created December 30, 2011 10:31
Find games with duplicate GameTeamStat records
var m = function() {
var key = this.stat_module_id + '_' + this.game_id + '_' + this.team_id;
emit(key, 1);
};
var r = function(k,vals) {
var sum = 0;
for (var i in vals) {
sum += vals[i];
}
@dachev
dachev / gist:1272673
Created October 8, 2011 18:32
Increase logical volume size on 1and1 dedicated server
lvextend -L 400G /dev/mapper/vg00-home
xfs_growfs /home
@dachev
dachev / solutions.js
Created June 8, 2011 04:58
Greplin Solutions
// one
function palindrome(text) {
var longest = '';
for (var i = 0; i < text.length; i++) {
var charOne = text.charAt(i);
for (var j = text.length-1; j > i; j--) {
var charTwo = text.charAt(j);