Skip to content

Instantly share code, notes, and snippets.

View jdkanani's full-sized avatar
🎯
Focusing

Jaynti Kanani jdkanani

🎯
Focusing
View GitHub Profile
@jdkanani
jdkanani / server.js
Last active August 29, 2015 14:09 — forked from ziahamza/server.js
var http = require('http'),
fs = require('fs'),
path = require('path'),
exec = require('child_process').exec;
function pipeDoc(inputPath, finalType, stream) {
var finalPath = path.dirname(inputPath)
+ "/" + path.basename(inputPath).split('.')[0] + ".html";
var convCommand = 'unoconv -f ' + finalType + " " + inputPath;
exec(convCommand,function(err, stdout, stderr) {
@jdkanani
jdkanani / main.js
Last active December 15, 2015 11:58
RequireJS shim to use Backbone-associations.js.
require.config({
paths: {
'jquery': 'vendor/jquery',
// -----------------------------------
// Use AMD versions of Backbone/Underscore : https://github.com/amdjs
'underscore': 'vendor/underscore-amd',
'backbone': 'vendor/backbone-amd',
// -----------------------------------
'backbone-associations': 'vendor/backbone-associations'
},
@jdkanani
jdkanani / save-and-fetch.js
Last active December 18, 2015 17:59
This example demonstrates how to incrementally load and save object graphs using Backbone-associations. This is important because rarely, there would be a need to fetch (or save) a entire object hierarchy from the server.
var MyApp = {
context: {}
};
MyApp.context.departments = null;
MyApp.context.employees = null;
var counter = 100;
/**
* Initialization of associated models
@jdkanani
jdkanani / app.yaml
Created December 28, 2015 16:52
Static google app engine config file
application: static-doc
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /(.+)
static_files: public/\1
upload: public/(.*)
@jdkanani
jdkanani / ProviderService.java
Created December 16, 2012 07:07
OpenID for Java web application - OpenID Provider (OP)
package org.myprovider.services;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@jdkanani
jdkanani / ConsumerService.java
Created December 16, 2012 06:47
OpenID for Java Web application - Relying Party (RP)
package org.myconsumer.services;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.RequestDispatcher;
@jdkanani
jdkanani / keybase.md
Created June 4, 2017 10:46
keybase.md

Keybase proof

I hereby claim:

  • I am jdkanani on github.
  • I am jdkanani (https://keybase.io/jdkanani) on keybase.
  • I have a public key whose fingerprint is 8A3D 2354 49B2 0A6A 94FE EA38 4396 982C 976B AE5E

To claim this, I am signing this object:

@jdkanani
jdkanani / fetch-block-promise.js
Last active August 15, 2017 09:45
Fetches Ethereum block data using web3 APIs
export function fetchBlock (web3, blockNumber) {
return web3.eth.getBlock(blockNumber);
}
export function fetchTransactions (web3, txs) {
return new Promise((resolve, reject)=>{
let result = [];
let _resolved = false;
let callback = (err, obj) => {
@jdkanani
jdkanani / vuefire-init.js
Created August 28, 2017 19:28
vuexfire + vuefire
import Vue from 'vue';
import { VueFireMixin, firebaseMutations, bind, unbind } from '~/plugins/vuefire';
// vuefire init
export default function ({ store }) {
// use object-based merge strategy
// TODO This makes impossible to merge functions
const mergeStrats = Vue.config.optionMergeStrategies;
mergeStrats.firebase = mergeStrats.methods;
@jdkanani
jdkanani / swap.sh
Created October 25, 2017 04:55
Creating swap file for Ubuntu digitalocean
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
sudo sysctl vm.swappiness=10
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf
sudo sysctl vm.vfs_cache_pressure=50