Skip to content

Instantly share code, notes, and snippets.

View ghostbar's full-sized avatar

Jose-Luis Rivas ghostbar

View GitHub Profile
ghostbar@ur:~$ http_proxy=190.198.76.32:8080 curl -I "http://google.com"
HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8
Date: Sat, 15 Feb 2014 16:56:55 GMT
Expires: Mon, 17 Mar 2014 16:56:55 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 219
X-XSS-Protection: 1; mode=block
traceroute to 190.93.243.15 (190.93.243.15), 30 hops max, 60 byte packets
1 192.168.0.1 (192.168.0.1) 3.127 ms 3.940 ms 3.923 ms
2 * * *
3 * * *
4 * * *
5 * * *
6 * * *
7 * * *
8 * * *
9 * * *
; <<>> DiG 9.8.3-P1 <<>> @200.44.32.12 pastebin.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 32931
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;pastebin.com. IN A
SchemaName.findOne({
_id: TheObjectId
}).lean().exec(theExtenderFunction); /* the .lean() is to make it JSON and modifiable */
function theExtenderFunction (err, firstResponse) {
if (err)
throw err; /* please handle your errors */
AnotherSchema.findOne({
_id: firstResponse.theOtherObjectId
var socketio = require('socket.io-client');
var client = socketio.connect('ws://yahoobingo.herokuapp.com');
client.on('connect', function(){
console.log("Connected...");
var card = {};
var results = {
"B": [
function unkMH(req, res) {
var allowHeaders;
if (req.method.toLowerCase() === 'options') {
allowHeaders = ['Accept', 'Accept-Version', 'Content-Type', 'Api-Version', 'Authorization'];
if (res.methods.indexOf('OPTIONS') === -1) {
res.methods.push('OPTIONS');
}
res.header('Access-Control-Allow-Credentials', true);
res.header('Access-Control-Allow-Headers', allowHeaders.join(', '));
@ghostbar
ghostbar / server.coffee
Created July 23, 2013 07:36
This is the basic "static" server I use in most of my projects. Is using express, with 3 development stages and HTTP Basic Auth for staging. It supports pushState address when it cannot find an static file to match the request. It's supported by Heroku as well. If using with Heroku then make sure to create the NODE_ENV variable for the stage wan…
express = require "express"
app = express()
console.log app.settings.env
oneDay = 86400000
pushState = (req, res) ->
newUrl = req.protocol + '://' + req.get('Host') + '/#' + req.url
res.redirect newUrl
@ghostbar
ghostbar / lowercase_results.js
Created July 23, 2013 07:31
This was asked on angular@googlegroups. Azure servers have the params being case-sensitive and that's anti-consistency for how most people code today. So this is the easier solution using underscore/lodash. The `newObject` will end up with all the keys lowercased.
var search = $location.search();
var newObject = {};
_.each(search, function(value, key) {
newObject[key.toLowercase()] = value;
});
@ghostbar
ghostbar / main.coffee
Last active December 14, 2015 09:08
Figuring out how many colors got used on a css-file.
_ = require "lodash"
fs = require "fs"
array = fs.readFileSync("css-colors.txt").toString().split("\n")
result = _.countBy array, (data) ->
return data
console.log result
@ghostbar
ghostbar / resize.coffee
Created June 3, 2012 06:28
Resize images from a given directory
#!/usr/bin/env coffee
fs = require 'fs'
im = require 'imagemagick'
_ = require 'underscore'
srcdir = __dirname + '/enviar'
destdir = __dirname + '/done'
log = (message) ->
console.log message