Skip to content

Instantly share code, notes, and snippets.

View ghostbar's full-sized avatar

Jose-Luis Rivas ghostbar

View GitHub Profile
@ghostbar
ghostbar / deb-pooling-experimental
Created October 17, 2009 00:49
reprepro pooling system
#!/bin/sh
DCRET=/home/ghostbar/incoming-experimental
DCROT=/srv/reprepro.deb.rivco.info
for i in $( find $DCRET | grep ".changes" ); do
reprepro -Vb $DCROT include experimental $i
mkdir -p /home/ghostbar/debian.rivco.info/$( grep "Source: " $i | sed 's/Source: //' )/$( grep "Version: " $i | sed 1's/Version: //' | grep --max-count=1 - ).exp
for j in $( dcmd $i ); do
mv $j /home/ghostbar/debian.rivco.info/$( grep "Source: " $i | sed 's/Source: //' )/$( grep "Version: " $i | sed 1's/Version: //' | grep --max-count=1 - ).exp/
@ghostbar
ghostbar / git-empty-branch
Created October 20, 2009 01:46
creates a git empty branch
#!/bin/sh
# creating a git empty branch
# it takes as arg the name for the new branch
git-symbolic-ref HEAD refs/heads/$1
rm .git/index
git clean -fdx
git commit --allow-empty -m "Initial empty branch commit"
# Most GPRS phones don't reply to LCP echo's
lcp-echo-failure 0
lcp-echo-interval 0
# Keep pppd attached to the terminal:
# Comment this to get daemon mode pppd
nodetach
# Debug info from pppd:
# Comment this off, if you don't need more info
<!doctype html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body>
<img id="bg" src="/img/bg.jpg">
<p>Content</p>
</body>
</html>
@ghostbar
ghostbar / script.js
Created September 13, 2011 05:15
Script for swapping img's src attr synced with tabs from jQueryUI
/* @author Jose Luis Rivas <[email protected]>
*
* @desc swaping full-background pages with jQuery UI's Tabs plugin events.
*/
$(document).ready(function() {
$( "#slides" ).bind( "tabsshow", function(event, ui) {
var tabattr = $('.ui-state-active').find('a').attr('href');
@ghostbar
ghostbar / app.coffee
Created February 12, 2012 01:49
How to read session from Redis with Express + Socket.IO in CoffeeScript
class App
express = require 'express'
redis = require 'redis'
RedisStore = require('connect-redis')(express)
sessionStore = new RedisStore()
# These will be used only on ioController()
fs = require 'fs'
parseCookie = require('connect').utils.parseCookie
@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
@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 / 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 / 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