Skip to content

Instantly share code, notes, and snippets.

View Checksum's full-sized avatar
:octocat:
Doing stuff

Srinath Sankar Checksum

:octocat:
Doing stuff
View GitHub Profile
@Checksum
Checksum / Canvas_Viewport.html
Created February 25, 2012 08:19
Fit canvas to viewport size for mobile devices
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Fit canvas to viewport for mobile devices</title>
<style>
* {
margin: 0;
padding: 0;
}
@Checksum
Checksum / fb_linkify.js
Created June 2, 2012 15:43
Bookmarklet to remove Facebook app signin links
(function() {
var links = document.querySelectorAll('.ogAggregationSubstorySlideHeadline > a');
for( var i=0, len=links.length; i < len; i += 1) {
var url = links[i].getAttribute('href');
url = decodeURIComponent(url.split("?")[1].split("&")[2].split("=")[1]);
links[i].setAttribute('href',url);
links[i].setAttribute('target','_blank');
}
}());
@Checksum
Checksum / PHP_SESSION.php
Created June 9, 2012 08:17
Stronger PHP Session IDs
<?php
// Generating stronger PHP session IDs
// Change from default PHPSESSID
ini_set('session.name','my_cookie');
// Use only cookies to prevent session ID hijacking
ini_set('session.use_cookies', 'true');
ini_set('session.use_only_cookies', 'true');
@Checksum
Checksum / JSON_response.js
Created July 27, 2012 06:36
Node.js get JSON response
require('http').request({
host: 'example.com',
path: '/path/to/get',
method: 'GET'
}, function(res) {
res.setEncoding('utf8');
var body = '';
res.on('data', function(chunk) {
body += chunk;
});
@Checksum
Checksum / gist:3291825
Created August 8, 2012 03:35
Macbook Retina Hardware Details
// A few terminal commands to determine SSD, display manufacturer
// Display Manufacturer
ioreg -lw0 | grep \"EDID\" | sed "/[^<]*</s///" | xxd -p -r | strings -6
LPXXXX = LG
LSNXXXX = Samsung
// SSD Manufacturer
@Checksum
Checksum / README.md
Last active December 10, 2015 20:48 — forked from mbostock/.block

This simple force-directed graph shows character co-occurence in Les Misérables. A physical simulation of charged particles and springs places related characters in closer proximity, while unrelated characters are farther apart. Layout algorithm inspired by Tim Dwyer and Thomas Jakobsen. Data based on character coappearence in Victor Hugo's Les Misérables, compiled by Donald Knuth.

@Checksum
Checksum / markdown.py
Last active August 29, 2015 14:07
Custom Markdown extension in Python
import re
import markdown2
class CustomMarkdown(markdown2.Markdown):
"""
Custom markdown processor that we use for task list
"""
reTaskList = re.compile('''
(?P<prefix>[\r\n|\n|\r]*)

Keybase proof

I hereby claim:

  • I am Checksum on github.
  • I am checksum (https://keybase.io/checksum) on keybase.
  • I have a public key whose fingerprint is EEA1 CD10 320D 497A B440 F6BD 45DD 4E24 58A5 101A

To claim this, I am signing this object:

@Checksum
Checksum / postgresql-json-queries.md
Last active January 14, 2020 06:11
Collection of queries to manipulate JSONB in PostgreSQL
CREATE TABLE users(
  id serial not null primary key,
  username text not null
);

CREATE TABLE tweets(
  id serial not null primary key,
  content jsonb default('{}')
);
@Checksum
Checksum / postgresql-event-trigger.sql
Created August 1, 2018 07:20
Automatically create column on new tables using PostgreSQL event triggers
-- Function to automatically create a user_id column for new tables with name starting with user_
create or replace function create_user_id_column()
returns event_trigger
language plpgsql volatile as
$$
declare
obj record;
identity text[];
begin
for obj in select * from pg_event_trigger_ddl_commands()