Skip to content

Instantly share code, notes, and snippets.

#!/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 chosen 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.
# Jachin - I changed this so I could run just the awk part.

Keybase proof

I hereby claim:

  • I am jachin on github.
  • I am jachin (https://keybase.io/jachin) on keybase.
  • I have a public key whose fingerprint is 3311 FDDB 2F3F A5F4 942A 41BB CE61 3961 68A6 2428

To claim this, I am signing this object:

@jachin
jachin / csv_to_psv.py
Created June 21, 2011 04:32
Convert CSV file to Pipe Delineated File
import argparse
import csv
parser = argparse.ArgumentParser(description='Converts a regular CSV to a piple delimited file with no quotes.')
parser.add_argument('csv_file', help='The CSV file to parse.')
args = parser.parse_args()
csv_reader = csv.reader(open(args.csv_file, 'rb'), delimiter=',', quotechar='"')
@jachin
jachin / select_the_primary_key_for_a_table.sql
Created June 21, 2011 04:33
Select the primary key for a table
SELECT k.column_name
FROM information_schema.table_constraints t
JOIN information_schema.key_column_usage k
USING(constraint_name,table_schema,table_name)
WHERE t.constraint_type='PRIMARY KEY'
AND t.table_schema='db'
AND t.table_name='tbl';
@jachin
jachin / gist:1081057
Created July 13, 2011 19:05
Setting up Apache2 Username/Password

Initial Create

htpasswd -c /usr/local/apache/passwd/passwords rbowen

This will create a new username/password file at /usr/local/apache/passwd/passwords with the username rbowen. It will then ask you to enter a password and confirm it.

@jachin
jachin / New Basic Tab.scpt
Created August 23, 2011 01:47
New Terminal Tab
-- `menu_click`, by Jacob Rus, September 2006
--
-- Accepts a list of form: `{"Finder", "View", "Arrange By", "Date"}`
-- Execute the specified menu item. In this case, assuming the Finder
-- is the active application, arranging the frontmost folder by date.
on menu_click(mList)
local appName, topMenu, r
-- Validate our input
@jachin
jachin / toggle_foreign_key_constraints.sql
Created September 1, 2011 21:45
MySQL – Toggle Foreign Key Checks or Constraints
-- Toggle off
SET foreign_key_checks = 0;
-- Toggle on
SET foreign_key_checks = 1;
@jachin
jachin / revert_svn_merge_info.sh
Created September 2, 2011 20:27
Revert svn (subversion) merge info only changes after a merge (and before a commit).
FILES=`svn status | grep "^ M " | sed s/" M "// | tr '\n', ' '`
svn revert $FILES
@jachin
jachin / mysql.sql
Created September 29, 2011 20:28
MySQL Cheat Sheet
# Create database.
CREATE DATABASE some_database_name;
# Create a user with all the priviliges for the database.
GRANT ALL PRIVILEGES ON some_database_name.* TO some_user@'localhost' IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
# Make sure our changes will get used.
FLUSH PRIVILEGES;
# Sorting in descending order.
@jachin
jachin / htpasswd_reference
Last active September 29, 2015 22:38
htpasswd reference
# This is a command line too for apache's basic authentication management.
# CAUTION: make sure /some/path/to/a/file/named/htpasswd is outside of any directory inside the web root.
# To initially create the password
htpasswd -c /some/path/to/a/file/named/htpasswd initialUsername
# To add another user to the same file
htpasswd /some/path/to/a/file/named/htpasswd newUsername