Skip to content

Instantly share code, notes, and snippets.

View jasonm23's full-sized avatar

Jason Milkins jasonm23

View GitHub Profile
@jasonm23
jasonm23 / sed examples.markdown
Created May 10, 2010 21:57
Column edits with sed / regexp

Ignore this - but if you are looking to do column edits, use unix cut it's made for this job.

Column edits with sed

Assuming you have a regular tabulated text file, e.g. a directory listing.

Extract columns from 15 - 29 for the entire input. ls -l | sed 's/(^.{14})(.{14})(.*)/\2/' # ^---^ ^---------^ ^--------^ ^---^ ^

input \1= \2= \3= +---- output only \2 (c15-c29)

@jasonm23
jasonm23 / Flex_Update_Code_Tasks.js
Created May 11, 2010 23:32
#Eclipse Monkey, #FlexBuilder: Find @todos and @fixmes in *.as, *.mxml & *.css, then add/update tasks
/*
* Menu: Flex > Tasks
* Kudos: Jason Milkins
* License: EPL 1.0
* DOM: http://download.eclipse.org/technology/dash/update/org.eclipse.eclipsemonkey.lang.javascript
* Eclipse Monkey script for FlexBuilder.
* Find @TODOs and @FIXMEs in *.as, *.mxml & *.css, then add/update tasks
*/
function main() {
@jasonm23
jasonm23 / get unique setting names from config master.
Created May 13, 2010 22:45
get unique setting names from config master
cat config_en.xml | grep -o -e '<setting key="[^ ]*"' | sort | uniq | sed -e 's/[^\=]*="\([^"]*\).*/\1/'
grep '<eventImage' config_en.xml | sed -e 's/[^\=]*\="\([0-9]*\)" value\="\([^.]*\)\.png"\/>/\1 \2/' | cat -n | wra b c; do echo "INSERT INTO event_type_numbers VALUES($a, '$b', '$(ds)', '$(ds)', 1, $(grep $c types.txt | sed 's/\([0-9]*\).*/\1/'));"; done
# find <eventImage nodes and grab their name value pairs, add line numbers, while read and split into a, b, c, (alias wra) then create a sql insert, $(ds) is a datestamp alias, then define the last column by searching for the image name in a list called types, and insert the associated ID num. and done.
html, body {color: #193440; background: url(../images/300-ACD3E6-fff.png) repeat-x #fff; }
.page-header {color: white; background: url(../images/101-3B5F87-ACD3E6.png) repeat-x #3F606E;}
.page-header .navigation.main-nav a {
background: url(../images/30-3E547A-242E42.png) repeat-x #242E42;
}
.page-header .navigation.main-nav li.current a {
color: #222;
background: url(../images/30-DBE1E5-FCFEF5.png) repeat-x #FCFEF5;
border-top: 1px solid white;
border-left: 1px solid white;
configId = Configuration.find(:first).id
c = Configuration.create Configuration.find(:first).attributes
klasses = [Menu, Translation, BookingMarketName, CornerMarketName, ScoreMarketName, Service, AllowDomain]
klasses.each { |klass|
klass.find(:all, :conditions => { :configuration_id => configId } ).each { |item|
o = klass.create item.attributes
o.configuration_id = c.id
#!/usr/bin/ruby
# convert a legacy config.xml
require 'rubygems'
require 'active_support'
require 'rexml/document'
include REXML
stdin = ARGF.read
@jasonm23
jasonm23 / SockPost
Created May 25, 2010 01:56
Rename to pattern with bash/for loop
for a in `ls` ; { mv $a ${a//pattern/replace} };