Skip to content

Instantly share code, notes, and snippets.

View vasanthk's full-sized avatar

Vasa vasanthk

View GitHub Profile
@vasanthk
vasanthk / directory.inc
Created November 19, 2013 22:55
Huge Inserts
// Fields by type
$int_fields = [
'permanent' => check_plain( $form_state['values']['additional']['permanent_directory'] ),
'app_id' => $app_info->id,
'level_1_field_id' => check_plain( $form_state['values']['level1']['level1_field'] ),
'level_2_field_id' => check_plain( $form_state['values']['level2']['level2_field'] )
];
$string_fields = [
'permanent_empty_template' => $form_state['values']['additional']['permanent_empty_template'],
'name' => check_plain( strtolower($form_state['values']['level1']['name']) )
@vasanthk
vasanthk / gist:8346114
Last active January 2, 2016 18:49
IE in Ubuntu
http://askubuntu.com/questions/190425/how-to-install-internet-explorer-multiple-versions
Update your PlayonLinux in Ubuntu:
wget -q "http://deb.playonlinux.com/public.gpg" -O- | sudo apt-key add -
sudo wget http://deb.playonlinux.com/playonlinux_precise.list -O /etc/apt/sources.list.d/playonlinux.list
sudo apt-get update
sudo apt-get install playonlinux
<html>
<head>
<script src="https://apis.google.com/js/client.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script>
function auth() {
var config = {
'client_id': 'OAUTH_CLIENT_ID',
'scope': 'https://www.google.com/m8/feeds'
};
@vasanthk
vasanthk / node-http-post-listener.js
Created April 20, 2015 12:13
A simple http server that listens for POST events at port 9000 and will print out the data it receives. This is useful for setting up as the url for a webhook and viewing/verifying the data that gets sent to that URL.
var app = require('http').createServer(handler);
var statusCode = 200;
app.listen(9000);
function handler (req, res) {
var data = '';
if (req.method == "POST") {
req.on('data', function(chunk) {
@vasanthk
vasanthk / keybase.md
Created April 21, 2015 18:58
Keybase.io

Keybase proof

I hereby claim:

  • I am vasanthk on github.
  • I am vasa (https://keybase.io/vasa) on keybase.
  • I have a public key whose fingerprint is 0872 9F46 406A ABE5 4EBC F69A 1BA1 6FF2 9340 598D

To claim this, I am signing this object:

{
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true
},
"ecmaFeatures": {
"arrowFunctions": true,
"blockBindings": true,
"classes": true,
@vasanthk
vasanthk / .eslintrc
Created April 27, 2015 23:05
React + ES6 --- ESLint
{
"parser": "babel-eslint",
"env": {
"browser": true,
"es6": true,
"node": true
},
"ecmaFeatures": {
"arrowFunctions": true,
"binaryLiterals": true,

Getting Started with NPM (as a developer)

If you haven't already set your NPM author info, now you should:

npm set init.author.name "Your Name"
npm set init.author.email "[email protected]"
npm set init.author.url "http://yourblog.com"

npm adduser

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@vasanthk
vasanthk / dispatcher-callback.txt
Created June 11, 2015 06:06
Difference between Dispatcher and callbacks
Dispatcher is used to broadcast payloads to registered callbacks. This is different from generic pub-sub systems in two ways:
1) Callbacks are not subscribed to particular events. Every payload is dispatched to every registered callback.
2) Callbacks can be deferred in whole or part until other callbacks have been executed.