Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
#
# Put me in cron.daily, cron.hourly or cron.d for your own custom schedule
# Running daily? You'll keep 3 daily backups
# Running hourly? You'll keep 3 hourly backups
NUM_BACKUPS_TO_KEEP=3
# Who wants to know when the backup failed, or
# when the binary logs didn't get applied
#!/bin/bash
# Usage: clusterctl start|stop
#
# Launches a local RabbitMQ cluster
#
# The name returned by `hostname -s` must resolve to 127.0.0.1
CLUSTER_SIZE=4
NODENAME_PREFIX='rmq'
@caot
caot / SortedArray
Last active August 29, 2015 14:02 — forked from kmdarshan/gist:6719785
Given a sorted array that has been transposed (that is, a portion has been removed from one end and attached to the other), write a function to determine if a given number is present in the array. Example: (7, 8, 9, 10, 1, 2, 3, 4, 5, 6) => find 9, 5, 11;
class SortedArray {
static boolean ispresent(int[] a, int i) {
return i == find(a, 0, a.length - 1, i);
}
static int find(int[] a, int low, int high, int i) {
int m = low + (high - low) / 2;
if (i == a[m])
@caot
caot / easyiosapps
Last active August 29, 2015 14:08 — forked from fbeeper/easyiosapps
#!/bin/bash
#
# Using the information available in the new iOS8 simulator for each
# device/runtime (device.plist), this script creates a readable folder structure
# (no UDIDs, just simple device/runtime names). Inside that structure it creates
# soft links to your apps in development.
#
# You can run this script every time you install an app to your simulator, or
# you can simply call it to access this folder making sure it will always be
# updated :)
@caot
caot / zlib3.py
Created February 18, 2016 21:57 — forked from glassdfir/zlib3.py
import zlib,sys
def deflate( data ):
zlibbed_data = zlib.compress( data )
#remove byte 0-1(header) and the last four(checksum)
compressed_data = zlibbed_data[2:-4]
return compressed_data
def inflate(compressed_data2):
# -15 for the window buffer will make it ignore headers/footers
zlibbed_data2 = zlib.decompress(compressed_data2, -15)
@caot
caot / extract-pdf-pages.py
Last active June 5, 2016 02:15 — forked from jeetsukumaran/extract-pdf-pages.py
PDF Page Extraction/Selection in Python Using PyPDF
#! /usr/bin/env python
###############################################################################
##
## Copyright 2012 Jeet Sukumaran.
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
@caot
caot / build_R.md
Created September 15, 2016 20:40 — forked from mikelove/build_R.md
build R on cluster
@caot
caot / iOS-UploadImage.h
Created October 31, 2016 17:54 — forked from mombrea/iOS-UploadImage.h
example of a multi-part form post in objective-c
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"REST URL PATH"]];
NSData *imageData = UIImageJPEGRepresentation(image, 1.0);
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
[request setHTTPShouldHandleCookies:NO];
[request setTimeoutInterval:60];
[request setHTTPMethod:@"POST"];
NSString *boundary = @"unique-consistent-string";
@caot
caot / gcc_4.7_for_Fedora_22.sh
Created January 10, 2017 19:24 — forked from joka90/gcc_4.7_for_Fedora_22.sh
How to build and install gcc 4.7 for Fedora 22 alongside gcc 5.1
#!/bin/bash
#Install build dependencies
sudo dnf groupinstall "Development tools"
sudo dnf install mpfr-devel gmp-devel libmpc-devel zlib-devel glibc-devel.i686 glibc-devel
wget http://mirror2.babylon.network/gcc/releases/gcc-4.7.4/gcc-4.7.4.tar.bz2
tar xvfj gcc-4.7.4.tar.bz2
cd gcc-4.7.4