Skip to content

Instantly share code, notes, and snippets.

@oniryx
oniryx / switch_submodule_main_repo.sh
Created April 19, 2016 14:00
Move git submodule code into the git main repo
#! /bin/bash
#
# WARNING: You will lose all git history of the submodule
#
$submodule_path=''
$backup_path=''
rm -rf $submodule_path/.git
@oniryx
oniryx / init_sortable_rank.sql
Created May 9, 2012 08:25
Init sortable_rank when using propel with sortable behavior
/* Init sortable_rank without scope */
select @rank:=0;
update TABLE_NAME set sortable_rank=(@rank:=(@rank+1));
/* Init sortable_rank with scope */
select @range:=0;
update TABLE_NAME set sortable_rank=IF(@range!=SCOPE_COLUMN, @rank:=1 && (@range:=SCOPE_COLUMN), @rank:=@rank+1) order by SCOPE_COLUMN, PK_COLUMN;
@oniryx
oniryx / arrayToCSV.php
Created April 19, 2012 16:50
Export an array as downladable Excel CSV
/**
* Export an array as downladable Excel CSV
* @param array $header
* @param array $data
* @param string $filename
*/
function toCSV($header, $data, $filename) {
$sep = "\t";
$eol = "\n";
$csv = count($header) ? '"'. implode('"'.$sep.'"', $header).'"'.$eol : '';
@oniryx
oniryx / encrypt_decrypt.php
Created March 14, 2012 14:26
Encrypt and Decrypt data in PHP compatible with C# mechanism
<?php
// Resource: http://stackoverflow.com/questions/4329260/cross-platform-php-to-c-sharp-net-encryption-decryption-with-rijndael
$iv = "45287112549354892144548565456541";
$key = "anjueolkdiwpoida";
$clear = "2310296|340105";
$encrypted = "B/DrahtonRfOMOgkCTcZRcuOdlpc68uKrNp9oCBpchY=";
$block = mcrypt_get_block_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
@oniryx
oniryx / README.md
Created March 3, 2012 06:56 — forked from minhajuddin/README.md
Script to retrieve content from google cache

#Script to extract to data from google cache This is a simple python script which retrieves content like your blog posts from googles cache, you can use this if your servers hard drive crashes or if a meteor hits your data center.

Remove the time.sleep code if you don't have more than 50 pages to retrieve.

Added check if file exists before downloading in case you need to rerun the script

##Original Source