Skip to content

Instantly share code, notes, and snippets.

View jcisio's full-sized avatar

Hai-Nam Nguyen jcisio

View GitHub Profile
@jcisio
jcisio / bash.git_prompt
Created February 20, 2013 21:20
Make bash prompt know about git
# Colors
NoColor="\033[0m"
Cyan="\033[0;36m"
Green="\033[0;32m"
Red="\033[0;31m"
Yellow="\033[0;33m"
# Chars
RootPrompt="\#"
NonRootPrompt="\$"
@jcisio
jcisio / update_nodes.php
Created January 27, 2013 11:16
Move taxonomy from node to content taxonomy fields. Use with drush.
<?php
/**
* @file
* Move taxonomy term from taxonomy_node table to field tables.
*/
$types = array(
array(
'type' => 'product',
'fields' => array(
@jcisio
jcisio / gist:4603181
Created January 23, 2013 08:35
MySQL table deduplication
-- Deduplication on all rows
CREATE TEMPORARY TABLE bad_temp AS SELECT DISTINCT * FROM your_table;
DELETE FROM your_table;
INSERT INTO your_table SELECT * FROM bad_temp;
-- Deduplication on some rows
CREATE TEMPORARY TABLE bad_temp AS SELECT * FROM your_table GROUP BY field1, field2, field3;
DELETE FROM your_table;
INSERT INTO your_table SELECT * FROM bad_temp;