Skip to content

Instantly share code, notes, and snippets.

View rpfilomeno's full-sized avatar
💭
For Hire

Roger Filomeno rpfilomeno

💭
For Hire
View GitHub Profile
#!/bin/bash
## Copyright (C) 2009 Przemyslaw Pawelczyk <przemoc@gmail.com>
## License: GNU General Public License v2, v3
#
# Lockable script boilerplate
### HEADER ###
LOCKFILE="/var/lock/`basename $0`"
@rpfilomeno
rpfilomeno / Yeoman + Composer + Bower + AngularJS + SLIM
Created October 28, 2014 16:51
Yeoman + Composer + Bower + AngularJS + SLIM
1. Install composer (http://getcomposer.org/doc/00-intro.md#installation)
2. php composer.phar create-project slim/slim-skeleton server
3. npm install -g yo grunt-cli bower
4, npm install -g generator-angular
5. yo angular
6. bower install angular-bootstrap --save
7. edit bowerrc to make sure it points to the correct directory
8. cd server
9. php composer.phar slim-json-api
@rpfilomeno
rpfilomeno / Replication check
Created November 10, 2014 23:34
Postgres Tricks
On Master:
SELECT
client_addr,
sent_offset - (
replay_offset - (sent_xlog - replay_xlog) * 255 * 16 ^ 6 ) AS byte_lag
FROM (
SELECT
client_addr,
('x' || lpad(split_part(sent_location, '/', 1), 8, '0'))::bit(32)::bigint AS sent_xlog,
@rpfilomeno
rpfilomeno / yajl make install log
Created November 12, 2014 18:34
Building modsecurity-2.8.0
$./configure --with-yajl=/usr/local/include/yajl
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for style of include used by make... GNU
checking for gcc... gcc
@rpfilomeno
rpfilomeno / ICMP PING implementation in PHP
Last active August 29, 2015 14:10
PHP Code Snippets
function ping($host, $timeout = 1) {
/* ICMP ping packet with a pre-calculated checksum */
$package = "\x08\x00\x7d\x4b\x00\x00\x00\x00PingHost";
$socket = socket_create(AF_INET, SOCK_RAW, 1);
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => $timeout, 'usec' => 0));
socket_connect($socket, $host, null);
$ts = microtime(true);
socket_send($socket, $package, strLen($package), 0);
if (socket_read($socket, 255)) {
$result = microtime(true) - $ts;
@rpfilomeno
rpfilomeno / Linux Static IP
Last active August 29, 2015 14:11 — forked from fernandoaleman/Linux Static IP
Linux Networking
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static
@rpfilomeno
rpfilomeno / SOX convert ring tone to G.71-ULAW for Polycom
Last active August 29, 2015 14:11
SOX Commands for VOIP, Asterisk, Polycom, etc
# sox SuperMario.wav -r 8000 -U -c1 SuperMarioUL.wav
@rpfilomeno
rpfilomeno / Debugging SIP Packets Using Ngrep
Last active August 29, 2015 14:11
Debugging SIP Packets
# ngrep -W byline -d eth0 port 5060
Capture to file
# ngrep -W byline -d eth0 port 5060 -O capture_file
Show INVITE only
# ngrep -W byline -d eth0 INVITE
HTTP Packets
# ngrep -t '^(GET|POST) ' 'src host 12.13.14.15 and tcp and dst port 80'
@rpfilomeno
rpfilomeno / 3D Models
Last active August 29, 2015 14:11
Hobby Crafts
http://cp.c-ij.com/en/contents/3156/03373/index.html
http://www.craftsy.com/project/paper-crafts?page=1
http://global.yamaha-motor.com/yamahastyle/entertainment/papercraft/animal-japan/fukuro/
@rpfilomeno
rpfilomeno / Excel Tricks
Created December 17, 2014 11:15
MS Office Tricks
Check if value is in column range
=IF(ISNA(VLOOKUP(<single column I value>,<entire column E range>,1,FALSE)),FALSE, TRUE)