Skip to content

Instantly share code, notes, and snippets.

View inadarei's full-sized avatar

Irakli Nadareishvili inadarei

View GitHub Profile
@inadarei
inadarei / knockoutAdvancedGist.html
Created May 9, 2012 06:32
Knockout Tutorial sample HTML snippet
<!-- snippet of loading indicator -->
<div data-bind="if: loading().length">
<div class="alert alert-info">
Loading...
</div>
</div>
<!---- snippet of binding countries and languages dropdowns to Knockout.js model. -->
var UserModel = function () {
var self = this;
// Somewhat sophisticated loading flag that supports parallel loading of multiple endpoints.
self.loading = ko.observableArray();
// Encapsulating the entire form in a property, so we can use ko.mapping in a safe way.
// If properties were directly on the model, we'd have to re-init model every time we
// load data, which could lead to unwanted consequences.
self.user = ko.observable();
@inadarei
inadarei / .tm_properties
Created July 25, 2012 03:23
Customizing Textmate2 Alpha ~/.tm_properties
# This goes into ~/.tm_properties
# For mor configuration options of things not exposed through the menu in TM Alpha:
# http://blog.macromates.com/2011/git-style-configuration/ and:
# https://gist.github.com/1478685#gistcomment-69755
tabSize = 2
showInvisibles = true
softTabs = true
@inadarei
inadarei / responsiveiframe.html
Created August 30, 2012 19:20
ResponsiveIframes
<!-- Activate responsiveness in the "child" page -->
<script src="/js/responsiveiframe.js"></script>
<script>
var ir = responsiveIframe();
ir.allowResponsiveEmbedding();
</script>
<!-- Corresponding code in the "parent" page -->
<script src="/js/jquery.js"></script>
<script src="/js/responsiveiframe.js"></script>
@inadarei
inadarei / node_debian_init.sh
Created September 24, 2012 03:20 — forked from peterhost/node_debian_init.sh
Daemon init script for node.js based app/server (DEBIAN/UBUNTU)
#!/bin/sh
# ------------------------------------------------------------------------------
# SOME INFOS : fairly standard (debian) init script.
# Note that node doesn't create a PID file (hence --make-pidfile)
# has to be run in the background (hence --background)
# and NOT as root (hence --chuid)
#
# MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit
# INIT-INFO RULES http://wiki.debian.org/LSBInitScripts
# INSTALL/REMOVE http://www.debian-administration.org/articles/28
def disable_notifications!
auth_url = "https://twitter.com/login"
notifications_url = "https://twitter.com/settings/notifications"
agent = Mechanize.new
page = agent.get(auth_url)
puts "DISABLING NOTIFICATIONS for #{self.username}"
puts "Logging in..."
page.forms_with(:action => 'https://twitter.com/sessions') do |forms|
@inadarei
inadarei / base64.js
Created January 6, 2013 04:11
base64 encode/decode in Node.js
var url = "http://cdn1.giltcdn.com/images/share/uploads/0000/0001/7250/172502872/420x560.jpg";
var encoded = new Buffer(url).toString('base64');
var decoded = new Buffer(encoded, 'base64').toString('ascii')
console.log(encoded);
console.log(decoded);
@inadarei
inadarei / json-example.js
Created June 4, 2013 22:20
JSON Example
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
Pragma: akamai-x-cache-on, akamai-x-cache-remote-on, akamai-x-check-cacheable, akamai-x-get-cache-key, akamai-x-get-extracted-values, akamai-x-get-nonces, akamai-x-get-ssl-client-session-id, akamai-x-get-true-cache-key, akamai-x-serial-no
@inadarei
inadarei / testrequest.js
Created August 1, 2013 20:27
Node.js compounding http request latency problem
/**
Some relevant links along the way:
https://github.com/joyent/node/issues/2809
https://github.com/joyent/node/issues/877
**/
var http = require('http');