Skip to content

Instantly share code, notes, and snippets.

View andreacfm's full-sized avatar

Andrea Campolonghi andreacfm

View GitHub Profile

Keybase proof

I hereby claim:

  • I am andreacfm on github.
  • I am andreacfm (https://keybase.io/andreacfm) on keybase.
  • I have a public key ASC84I4vtwhmfba9gJAyIaNPxIdCTN60aM0uVeNHcl-BXAo

To claim this, I am signing this object:

@andreacfm
andreacfm / lambda_env.rb
Created July 23, 2014 15:45
lambda env construct
class Pippo
attr_accessor :name
def initialize
greet(&greeter)
end
def greet &block
p block.call(self)
end
#!/bin/sh
# Script for managing build and version numbers using git and agvtool.
# Change log:
# v1.0 18-Jul-11 First public release.
# v1.1 29-Sep-12 Launch git, agvtool via xcrun.
version() {
#!/bin/bash
#
# (Above line comes out when placing in Xcode scheme)
#
# Inspired by original script by incanus:
# https://gist.github.com/1186990
#
# Rewritten by martijnthe:
# https://gist.github.com/1379127
#
@andreacfm
andreacfm / gist:7689669
Last active December 29, 2015 15:19 — forked from c0diq/gist:2213492
Increment the build number when creating an AdHoc build
#!/bin/bash
if [[ $CONFIGURATION == *AdHoc* ]]; then
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" ${PROJECT_DIR}/${INFOPLIST_FILE})
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" ${PROJECT_DIR}/${INFOPLIST_FILE}
fi
#remove redis key by match
redis-cli KEYS "development:*" | xargs redis-cli DEL
@andreacfm
andreacfm / pg_performance.sql
Last active December 17, 2015 03:59
SHELL AND SIMPLE SCRIPTS
SELECT
'cache hit rate' AS name,
sum(heap_blks_hit) / (sum(heap_blks_hit) + sum(heap_blks_read)) AS ratio
FROM pg_statio_user_tables;
GO
SELECT
sum(idx_blks_read) as idx_read,
sum(idx_blks_hit) as idx_hit,
@andreacfm
andreacfm / rspec_xhr.rb
Last active January 13, 2018 00:51
Blog code
get :show, id: 1 # normal request
xhr :get, :show, id: 1 # exactly the same request, This time fake to be an xhr call. request.xhr? will be true
@andreacfm
andreacfm / tar
Created October 26, 2012 06:35
tar with bzip2
tar -c --bzip2 -f foo.tar foo/
@andreacfm
andreacfm / ffmpeg_convert.sh
Created August 31, 2012 09:27
convert avi files to m4v
ffmpeg -i file.AVI -vcodec copy -acodec libfaac file.m4v