Skip to content

Instantly share code, notes, and snippets.

@korczis
korczis / deferredRequest.js
Last active August 22, 2017 20:05
Deferred wrapper of cherio request
var deferred = require('deferred'),
request = require('request'),
cheerio = require('cheerio');
var deferredRequest = function(url) {
var d = deferred();
request(url, function (err, resp, body) {
if(err) {
d.reject(new Error("Unable to fetch '" + url + "', reason: " + err));
@plentz
plentz / nginx.conf
Last active March 31, 2024 18:40
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@aboma
aboma / ember.select2.js
Last active February 7, 2021 17:07
select2.js enabled select box view for ember.js
// Select box utilizing Select2 functionality that overrides Ember.Select;
// Define view in the same way that you would an Ember.Select view.
// Additional attributes supported are: width, allowClear, and closeOnSelect;
// Example view:
// {{ view App.Select2
// viewName="fieldValueSelect2"
// prompt="Please select a value list"
// contentBinding="controller.fieldValuesLists"
// optionLabelPath="content.name"
// optionValuePath="content.id"
#! /usr/bin/env ruby
require 'rubygems'
require 'fog'
require 'fileutils'
require 'yaml'
module Apollo
class AwsConsole
@PRotondo
PRotondo / traceroute.hs
Last active July 30, 2017 15:53
Haskell traceroute over icmp
#!/usr/bin/env runhaskell
-- Haskell traceroute over icmp
-- now with ByteString to avoid new errors produced
-- by the deprecated recvFrom from Network.Socket
import Control.Monad
import Data.Bits(complement)
import Data.ByteString(unpack,pack)
import Data.List
@lukas-vlcek
lukas-vlcek / gist:4673027
Last active January 19, 2021 15:03
Čeština v elasticsearch
#!/bin/sh
# download
wget http://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.20.4.zip
# unzip and start
unzip elasticsearch-0.20.4.zip
cd elasticsearch-0.20.4
# remove data in case you have defined some analyzers in the past (e.g. stop/start)
rm -rf data/
@ninjascience
ninjascience / Gruntfile.js
Created January 24, 2013 17:52
Gruntfile.js for testing with Jasmine and RequireJS and using Istanbul for coverage.
module.exports = function(grunt) {
'use strict';
// Project configuration.
grunt.initConfig({
meta : {
// Specify where our test files are. Once we get all the tests switched over we can use 'test/js/**/*.spec.js' to automatically load all tests.
specs : ['test/js/src/**/*.spec.js'],
bin : {
coverage: 'js/bin/coverage'
@guerrerocarlos
guerrerocarlos / main.js
Created September 6, 2012 05:07
loading socket.io using require.js
// Require.js allows us to configure shortcut alias
require.config({
// The shim config allows us to configure dependencies for
// scripts that do not call define() to register a module
shim: {
'socketio': {
exports: 'io'
},
'underscore': {
exports: '_'
@bobbydavid
bobbydavid / app.js
Created May 8, 2012 23:46
socket.io in Express 3
var express = require('express')
, http = require('http')
, connect = require('connect')
, io = require('socket.io');
var app = express();
/* NOTE: We'll need to refer to the sessionStore container later. To
* accomplish this, we'll create our own and pass it to Express
* rather than letting it create its own. */
var sessionStore = new connect.session.MemoryStore();
@jackdoe
jackdoe / rack-and-mongo.rb
Created March 6, 2012 17:48
mongoid stored rack session Rack::Session::RackAndMongo
# inspired by https://github.com/biilmann/mongo_sessions
require 'rack/session/abstract/id'
class Session
include Mongoid::Document
field :sid
field :data
field :ts, type: Integer
index :sid, unique: true #dont forget Session.create_indexes
def Session.find_by_sid(sid)
Session.first(conditions: {sid: sid})