Skip to content

Instantly share code, notes, and snippets.

@korczis
korczis / deferredRequest.js
Last active Aug 22, 2017
Deferred wrapper of cherio request
View deferredRequest.js
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 Oct 14, 2021
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
View nginx.conf
# 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 Feb 7, 2021
select2.js enabled select box view for ember.js
View ember.select2.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"
View apollo-aws.rb
#! /usr/bin/env ruby
require 'rubygems'
require 'fog'
require 'fileutils'
require 'yaml'
module Apollo
class AwsConsole
@PRotondo
PRotondo / traceroute.hs
Last active Jul 30, 2017
Haskell traceroute over icmp
View traceroute.hs
#!/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 Jan 19, 2021
Čeština v elasticsearch
View gist:4673027
#!/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 Jan 24, 2013
Gruntfile.js for testing with Jasmine and RequireJS and using Istanbul for coverage.
View Gruntfile.js
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 Sep 6, 2012
loading socket.io using require.js
View main.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
socket.io in Express 3
View app.js
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 Mar 6, 2012
mongoid stored rack session Rack::Session::RackAndMongo
View rack-and-mongo.rb
# 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})