Skip to content

Instantly share code, notes, and snippets.

var interval = setInterval(function() {
var expandPoints = $(".octicon.octicon-unfold");
expandPoints ? expandPoints.click() : clearInterval(interval);
}, 2000);
@gurdotan
gurdotan / gist:3596190
Created September 2, 2012 09:27
Git 3-way merge with meld
### Add the following to HOME/tools/bin/gitmerge
#!/bin/sh
meld $2 $1 &
sleep 0.5
meld $1 $3 &
sleep 0.5
meld $2 $4 $3
### Make it executable
@gurdotan
gurdotan / slc-initd-example.sh
Created December 24, 2014 10:36
Node.js SLC init.d daemon script example
#!/usr/bin/env bash
#
# An example init script for running a Node.js process as a service
# using Strongloop's slc as the process monitor. For more configuration options
# associated with slc, see: http://docs.strongloop.com/display/public/SLC/slc+run.
# This script assumes you've installed slc globally with `npm install -g strongloop`.
#
# You will need to set the environment variables noted below to conform to
# your use case, and change the init info comment block.
#
@gurdotan
gurdotan / MyDtoSerializer.java
Created August 2, 2016 07:41
Jackson Custom JSON Serializer
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
public class UiNotificationSerializer extends JsonSerializer<MyDto> {
@Override public void serialize(MyDto dto, JsonGenerator generator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
@gurdotan
gurdotan / mongo_alias.sh
Created June 14, 2016 12:31
SSH - connect to MongoDB with authentication remotely
alias mongo-connect="echo \"db.auth('user','password')\" | pbcopy; ssh -t dashboard \"mongo 10.0.1.107:27017/db_name\""
@gurdotan
gurdotan / s3-folder-range-size.sh
Last active June 1, 2016 13:03
S3: sum size of all objects in bucket/folder
IFS=$'\n'; arr=(`for d in {0..182}; do date -d "2015-12-01 + $d days" +'%Y%m%d'; done`); for i in ${arr[@]} ; do aws s3 ls s3://bucket-name/production/dt=$i/ | tr -s " " | cut -f3 -d" " | paste -sd+ - | bc | numfmt --to=iec-i --suffix=B --padding=7 ; done
if (GrowInsights.UserInsights.PayInsights.PayRankByGenre[Genre.Educational] > 3) {
// Adapt gameplay to a potential payer
// Examples: offer welcome bundle, block ads,
// report user as payer to your push notification platform etc.
}
var BackboneViewExtensions = {
mixin : function(from) {
var to = this.prototype;
// we add those methods which exists on `from` but not on `to` to the latter
_.defaults(to, from);
// ...and we do the same for events and triggers
_.defaults(to.events, from.events);
// Define a router for the games sub-application
var GamesRouter = Backbone.Router.extend({
routes: {
"": "root",
"games": "index",
"games/:id": "showGame"
},
root : function() { /*...*/ },
index : function() { /*...*/ },
showGame : function(id) { /*...*/ }
RootApp.on("switchApp", function(appName, args) {
// Assuming the Root app has already instantiated all sub-apps
// and cached the instances by their names, fetch the app instance
var currentApp = RootApp.getSubappInstance(appName);
// If the app we're switching to is the currently active one, do nothing
if (RootApp.currentApp === currentApp) return;
// Stop the previously running app. Safe-guard with `if` in case