Skip to content

Instantly share code, notes, and snippets.

@bryanmacfarlane
bryanmacfarlane / messagequeue.js
Last active July 28, 2019 23:23
node.js http long polling server. using a messaging as an example of longpoll usage.
//
// Crude node.js longpoll example via a simple message queue
//
//--------------------
// app.js
//--------------------
var queue = require('./queue/messagequeue');
app.get('/messages/:queueName/:lastMsgId', queue.getMessages);
app.post('/messages/:queueName', queue.postMessages);
@amitmerchant1990
amitmerchant1990 / stylish.css
Last active December 28, 2018 00:32
GitHub Fixed Header for better accessibility.
/**
1. Install the Stylish(https://chrome.google.com/webstore/detail/stylish/fjnbnpbmkenffdnngjfgmeleoegfcffe?hl=en) extension for Chrome.
2. Open up extension options and paste the whole CSS mentioned below.
3. Specify the domain name to be `github.com`.
4. Add a title and save.
*/
.header {
padding-top: 10px;
padding-bottom: 10px;
@tapi
tapi / UICollectionView+Registration.swift
Created April 4, 2016 16:38
Typed UITableView & UICollectionView Dequeuing in Swift
import UIKit
extension UICollectionReusableView {
/// The default implementation of `defaultIdentifier()` uses `NSStringFromClass(class)` rather than `String(class)` so that the module name is includded.
/// The hope being that this makes collisions unlikely making it unnnecessary to provide your own implementations.
public class func defaultIdentifier() -> String {
return NSStringFromClass(self)
}
}
@DoubleBrotherProgrammer
DoubleBrotherProgrammer / FindColumnInDatabase.sql
Created August 8, 2011 18:15
Find column across all SQL Server databases
/* Find column in all databases */
DECLARE @db_name varchar(100),
@col_name varchar(100),
@sql_statement nvarchar(MAX)
-- column you are looking for
SET @col_name = 'PLANNED_SAMPLE_ID'
-- fill cursor with database names
@ybogdanov
ybogdanov / platform.yml
Last active November 28, 2016 00:26
A manifest that describes "platform" agents that we run on every instance. See http://tech.grammarly.com/blog/posts/How-We-Deploy-Containers-at-Grammarly.html
# This is a manifest that describes "platform" agents that we run on every instance.
# It includes auxilary services that work alongside with the application containers
# to provide logging and monitoring.
#
# This file looks a bit tough, but that's what happens when you meet the reality.
# We have also pruned it a bit to remove our company specifics.
#
# You may notice "env", "role" and "track" variables. We specify them as EC2 instance
# tags and pass them to rocker-compose on every run. This allows us to distinguish
# instances and do basic service discovery and A/B testing.
@Baza207
Baza207 / UICollectionViewControllerExtensions
Last active September 14, 2016 15:10
A Swift extension for UICollectionViewController to allow setting and getting a UIRefresh control in the same manor as UITableViewController.
///
/// Extention functions for UICollectionViewController
///
extension UICollectionViewController {
/// Allows easy access to a collection view controller's refrsh control the same way as in a table view controller.
var refreshControl: UIRefreshControl? {
get {
return collectionView?.viewWithTag(140412014669856) as? UIRefreshControl
}
set {
@magiconair
magiconair / node-long-poll-1.js
Created February 1, 2011 15:27
Long polling server skeleton
/**
* Module import
*/
var express = require('express');
/**
* Port the server listens on
*/
var port = 3000;
@mathieue
mathieue / do-it.sh
Last active December 22, 2015 02:59
graphite + statsd install with chef-solo
# install chef-solo one line !
curl -L https://www.opscode.com/chef/install.sh | bash
# cookbooks have their rep: check the dir name == cookbook name
mkdir -p /opt/cookbooks
git clone https://github.com/hw-cookbooks/graphite
git clone https://github.com/opscode-cookbooks/apache2.git
git clone https://github.com/opscode-cookbooks/python.git
git clone https://github.com/opscode-cookbooks/runit.git
git clone https://github.com/opscode-cookbooks/memcached.git
@marshall007
marshall007 / retry-promise.coffee
Created July 28, 2014 20:15
Retries with exponential backoff using Bluebird
_ = require 'lodash'
Promise = require 'bluebird'
Promise.retry = (action, options = {}) ->
_.merge
max: 5
backoff: 500
, options
d = Promise.defer()
. (Resolve-Path "$env:LOCALAPPDATA\GitHub\shell.ps1")
If (Test-Path "cloud_package.cspkg") {
Remove-Item "cloud_package.cspkg" -Force
}
cd "WebRole"
iex "git reset --hard origin/master"
iex "git pull"
cmd /C "rmdir /S /Q node_modules"