Skip to content

Instantly share code, notes, and snippets.

View ivikash's full-sized avatar

Vikash Agrawal ivikash

View GitHub Profile
@ivikash
ivikash / colortest.py
Created March 23, 2018 11:06 — forked from justinabrahms/colortest.py
Small utility to test terminal support for 256-color output.
#!/usr/bin/env python
# Ported to Python from http://www.vim.org/scripts/script.php?script_id=1349
print "Color indexes should be drawn in bold text of the same color."
print
colored = [0] + [0x5f + 40 * n for n in range(0, 5)]
colored_palette = [
"%02x/%02x/%02x" % (r, g, b)
for r in colored
@ivikash
ivikash / ps4devtools.js
Created November 14, 2017 10:36 — forked from kdzwinel/ps4devtools.js
Gamepad - Chrome DevTools integration
(function(){
let gamepad = null;
let loopInterval = null;
window.addEventListener("gamepadconnected", connectHandler);
window.addEventListener("gamepaddisconnected", disconnectHandler);
function connectHandler(e) {
if (!gamepad) {
@ivikash
ivikash / ps4devtools.js
Created November 14, 2017 10:35 — forked from kdzwinel/ps4devtools.js
Gamepad - Chrome DevTools integration
(function(){
let gamepad = null;
let loopInterval = null;
window.addEventListener("gamepadconnected", connectHandler);
window.addEventListener("gamepaddisconnected", disconnectHandler);
function connectHandler(e) {
if (!gamepad) {
@ivikash
ivikash / unistore.js
Created October 24, 2017 13:59 — forked from developit/unistore.js
dead simple centralized state container ("store"), with preact bindings.
import { h, Component } from 'preact';
/** Creates a new store, which is a tiny evented state container.
* @example
* let store = createStore();
* store.subscribe( state => console.log(state) );
* store.setState({ a: 'b' }); // logs { a: 'b' }
* store.setState({ c: 'd' }); // logs { c: 'd' }
*/
.gist {
border-left: 3ex solid #eee;
position: relative;
}
.gist pre {
counter-reset: linenumbers;
}
.gist pre div:before {
@ivikash
ivikash / app.js
Last active December 11, 2015 03:19 — forked from tnylea/appjs
var app = require('http').createServer(handler)
, io = require('socket.io').listen(app)
, fs = require('fs')
var mongo = require('mongodb');
var d = new Date();
var Server = mongo.Server,
Db = mongo.Db,
<html>
<head>
<title>Simple Node JS and Socket IO Chat</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io.connect('http://localhost:5432');
// add a new chat message
socket.on('add_message', function (name, data) {
@ivikash
ivikash / Debugging Ruby Notes.html
Created March 19, 2012 17:56 — forked from daya/Debugging Ruby Notes.html
My notes from Aman Gupta's Debugging Ruby webinar by Engine Yard
<a href="http://en.wikipedia.org/wiki/Lsof">lsof</a>
----
show open files
lsof -nPp <pid>
<a href="http://linux.die.net/man/1/strace">strace</a>
------