Skip to content

Instantly share code, notes, and snippets.

View proudlygeek's full-sized avatar
🍕

Gianluca Bargelli proudlygeek

🍕
View GitHub Profile
@proudlygeek
proudlygeek / TestDecamelize.php
Created February 22, 2012 22:49
decamelize
<?php
require_once 'decamelize.php';
class TestDecamelize extends PHPUnit_Framework_TestCase
{
public function testOneCamel()
{
$rs = decamelize("camelCase");
$this->assertEquals($rs[0], "camel");
@proudlygeek
proudlygeek / oneliners.sh
Last active September 27, 2019 16:51
Bash one liners
##### GIT
# Removes all local branch
for branch in $(git branch | grep "feature/MAGENTA-"); do git branch -D $branch; done
# Remove all new files
for file in $(git status | grep "new file" | sed "s/#\tnew file://"); do git rm --cached $file; done
# Delete all remote branches
for remote_branch in $(git ls-remote); do if [[ $remote_branch =~ .*(feature/MAGENTA-([0-9|^130]).+).* ]]; then git push origin :${BASH_REMATCH[1]}; fi; done
@proudlygeek
proudlygeek / update_acl.rb
Created March 12, 2012 09:21 — forked from shaneog/update_acl.rb
Capifony Task to Set ACLs on Symfony2 app/cache and app/logs directories as per http://symfony.com/doc/current/book/installation.html
# Change ACL on the app/logs and app/cache directories
after 'deploy', 'deploy:update_acl'
# This is a custom task to set the ACL on the app/logs and app/cache directories
namespace :deploy do
task :update_acl, :roles => :app do
shared_dirs = [
app_path + "/logs",
@proudlygeek
proudlygeek / ciccio.sh
Created March 22, 2012 16:36
phpunit wav when all green : )
tv-testall() {
if [ $(pwd) != "/home/prouudlygeek/github/BookingSandbox" ]; then
echo -n "terravision test command failed: you are not in the correct path "
pwd
return 1
fi
php app/console doctrine:database:drop --env="test" --force
php app/console doctrine:database:create --env="test"
php app/console doctrine:schema:create --env="test"
php app/console doctrine:fixtures:load --env="test"

A Backbone.js demo app (Sinatra Backend)

Oct 16 2010

Updates

  • 04/10/2011 - Updated application.js and application.rb thanks to @rebo's comments

In this article, I will walk through some simple steps to get a [demo app][2] up and running with [Backbone.js][3] and [Sinatra][4] on [Heroku][5].

@proudlygeek
proudlygeek / Benchmark
Created March 27, 2012 07:33
Benchmark Fun
Flask 0.8
=========
```
Server Software: Werkzeug/0.8.3
Server Hostname: localhost
Server Port: 5000
Document Path: /
Document Length: 21 bytes
#include <stdio.h>
// The original function (adds two number and sets
// the results into the first one
void add(int *x, int *y)
{
*x = *x + *y;
}
void sub(int *x, int *y)
@proudlygeek
proudlygeek / reinvoke.cljs
Created April 9, 2012 21:57 — forked from alandipert/reinvoke.cljs
It's sweet IFn is a protocol in ClojureScript
(extend-type js/RegExp
cljs.core.IFn
(-invoke ([this s] (re-matches this s))))
(#"foo.*" "foobar") ;=> "foobar"
(#"zoo.*" "foobar") ;=> nil
(filter #".*foo.*" ["foobar" "goobar" "foobaz"]) ;=> ("foobar" "foobaz")
@proudlygeek
proudlygeek / gist:2352357
Created April 10, 2012 15:53 — forked from jasoncodes/gist:1223731
Installing Ruby 1.9.3 with rbenv
brew install rbenv
brew install ruby-build
brew install --HEAD https://raw.github.com/jasoncodes/homebrew/rbenv-vars/Library/Formula/rbenv-vars.rb # https://github.com/mxcl/homebrew/pull/7891
brew install readline
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.bash_profile
exec $SHELL -i # reload the shell
CONFIGURE_OPTS="--disable-install-doc --with-readline-dir=$(brew --prefix readline)" rbenv install 1.9.3-p125
rbenv global 1.9.3-p125
gem install bundler -v '~> 1.0.pre'
gem install git-up hitch gem-browse gem-ctags cheat awesome_print pry
@proudlygeek
proudlygeek / gist:2595758
Created May 4, 2012 16:01
Ruby Snippets
# Map alphabet letter to numbers 1
Hash[("a".."z").map.with_index {|x, i| [x, i] }]
#