Skip to content

Instantly share code, notes, and snippets.

View avargas's full-sized avatar

Angelo Vargas avargas

View GitHub Profile
@avargas
avargas / gist:5109610
Created March 7, 2013 16:53
returns an array of start and end ip ranges in int
def cidr_range(cidr):
ip, subnet = cidr.split('/')
ipint = ip2int(ip)
subnet = int(subnet)
mask = ''.join(['1' for num in range(subnet)] + ['0' for num in range(32 - subnet)])
inverted_mask = ''.join(['0' for num in range(subnet)] + ['1' for num in range(32 - subnet)])
mask_int = int(mask, 2)
@avargas
avargas / invalidate.py
Last active December 16, 2015 17:28
invalidates cloudfront files easily
import argparse, boto
AWS_ACCESS_KEY = ''
AWS_SECRET_KEY = ''
AWS_CLOUDFRONT_ID = ""
def invalidate (f, print_debug=False):
from boto.cloudfront import CloudFrontConnection
con = CloudFrontConnection(AWS_ACCESS_KEY, AWS_SECRET_KEY)
server {
root /www/site/;
server_name site.com *.site.com;
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires 360d;
}
@avargas
avargas / gist:7226558
Created October 30, 2013 02:58
emergency vnc
$ x11vnc -rfbport 1111 -display :1
#!/bin/sh
# Current as working as of 2012/4/17
# Xcode 4.3.2
PROJECT_ROOT="$HOME/SomeDirWhereYourProjectLives/XXXXXXXX"
WORKSPACE="$PROJECT_ROOT/XXXXXXXX.xcodeproj/project.xcworkspace"
CONFIG="AdHoc"
SCHEME="XXXXXXXX"
i could suggest you do this:
user 1:
id: 5
name: angelo
email: [email protected]
key/value:
['date subscribed', 02/17/2010],
['birthday', 02/17/1990]
<?php
// simple lock, prevent script from running multiple times at once
$lockfile = '/tmp/.run.php-lock-' . md5(implode('', array_slice($argv, 1)));
if (($lock = fopen($lockfile, 'w+')) === false) {
echo "fopen($lockfile) failed\n";
die(-1);
}
@avargas
avargas / a.js
Created February 7, 2017 21:12
window error ignore
// filter out stupid error messags
(function () {
const prev = window.addEventListener;
const ignore = ['__gCrWeb.autofill.'];
window.addEventListener = function (a, b, c) {
if (a === 'error') {
return prev(a, function (err) {
// if error is matched to ignore list, ignore it then
if (err && err.message && ignore.filter(t => err.message.indexOf(t) > -1).length) {
@avargas
avargas / cloudflare-update-ip-ranges.sh
Last active November 8, 2018 09:18
Cloudflare Nginx real ip cronjob
#!/bin/bash
# ref https://gist.githubusercontent.com/robsonsobral/a9071e56cc495763d727/raw/0763e9b0c627c5ab6e0281e604cdb4af40c2be62/cloudflare-update-ip-ranges.sh
#
#
# Location of the nginx config file that contains the CloudFlare IP addresses.
CF_NGINX_CONFIG="/etc/nginx/cloudflare"
# The URLs with the actual IP addresses used by CloudFlare.
CF_URL_IP4="https://www.cloudflare.com/ips-v4"
CF_URL_IP6="https://www.cloudflare.com/ips-v6"
@avargas
avargas / [email protected]
Created November 9, 2018 01:12
systemd service for php worker
[Unit]
Description=pdr worker serivice @ %I
After=network.target
[Service]
Type=simple
User=www-data
ExecStart=/usr/bin/php /app/live/bin/run-worker
ExecReload=/bin/kill -HUP $MAINPID