Skip to content

Instantly share code, notes, and snippets.

@twhitney11
twhitney11 / find-replace.php
Created September 29, 2012 05:14
Simple Recursive Find and Replace PHP CLI Script
<?php
/**
* Tyler Whitney
*
* PHP Command line script that recursively finds and replaces a string within files of directories.
*
* Useage: php script.php DIRECTORY SEARCH-STRING REPLACE-STRING (PARTIAL-FILE-NAME-MATCH)
*
* The script will replace all strings matching SEARCH-STRING within all files inside of DIRECTORY and its sub-directories with REPLACE-STRING.
* If you provide the option PARTIAL-FILE-NAME-MATCH it will only replace occurences in files that their filenames contain the partail search.
@yang
yang / gist:2419515
Created April 19, 2012 08:01
Bookmarklet to download Chrome extension files (CRX files) from Chrome webstore
If you want to access the source code of a Chrome extension, you need to get the .crx file. This bookmarklet downloads the .crx file for the Chrome extension you're viewing. You'll be prompted to install it; before dismissing the dialog, check in your Downloads directory. Then just unzip the .crx (it's a zip file).
javascript:window.open('https://clients2.google.com/service/update2/crx?response=redirect&x=id%3D' + /webstore\/detail\/([^\/]+)/.exec(window.location.href)[1] + '%26uc')
javascript:window.open%28%27https%3A//clients2.google.com/service/update2/crx%3Fresponse%3Dredirect%26x%3Did%253D%27%20%2B%20/webstore%5C/detail%5C/%28%5B%5E%5C/%5D%2B%29/.exec%28window.location.href%29%5B1%5D%20%2B%20%27%2526uc%27%29
@esperlu
esperlu / mysql2sqlite.sh
Created April 27, 2011 05:46
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite