This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function transformer(file, api) { | |
const j = api.jscodeshift; | |
const root = j(file.source); | |
const run = root | |
.find(j.CallExpression, { callee: { property: { name: "findTest" } } }) | |
.forEach(path => { | |
const object = path.value.callee.object; | |
const args = path.value.arguments; | |
const prop = path.value.callee.property; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# here we use /dev/sdc1 but it can be different | |
# make sure the flascard is umounted | |
umount /dev/sdc | |
# format flashcard | |
sudo mkfs.vfat -n 'marcio-pendrive' -I /dev/sdc | |
# create iso | |
mkisofs -l -o /home/marcio/arch.iso /home/marcio/dotfiles-master/arch | |
# create bootable flashcard | |
sudo dd bs=4M if=/home/marcio/arch.iso of=/dev/sdc status=progress && sync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActiveRecord::Migration | |
def exec_migration_with_ignore_errors(conn, direction) | |
begin | |
exec_migration_without_ignore_errors(conn, direction) | |
rescue => e | |
puts "Ignoring #{e}" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f.label :title => <label>Title</label> | |
f.text_field :title => <input type="text" /> | |
f.text_area :body, size: "60x12" => <textarea cols="60" rows="12" ></textarea> | |
f.submit "Create" => <input name="commit" type="submit" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from http://stackoverflow.com/a/4732119/1846480 and adapted from a comment to not require sudo | |
// It's also needed to pass the -ggdb. For instance gcc source.c -o target.o -w -ggdb | |
#include <sys/prctl.h> | |
void print_trace() { | |
char pid_buf[30]; | |
sprintf(pid_buf, "%d", getpid()); | |
char name_buf[512]; | |
name_buf[readlink("/proc/self/exe", name_buf, 511)]=0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import generate from 'babel-core/lib/generation'; | |
let file; | |
function print(ast) { | |
// duck type NodePath | |
if (ast.node) { | |
ast = ast.node; | |
} | |
console.log(generate(ast, file.opts, file.code).code); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# taken from http://www.unix.com/302182212-post4.html | |
while true | |
do | |
case $# in 0) break ;; esac | |
case $1 in | |
-d|--dir) shift; dir=$1; shift ;; | |
-u|--user) shift; user=$1; shift ;; | |
-a|--all) shift; all=true ;; | |
-|--) shift; break;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import DS from 'ember-data'; | |
function model(clazz) { | |
var propertyNames = Object.getOwnPropertyNames(clazz.prototype); | |
var hash = {} | |
propertyNames.forEach( (prop) => { | |
if (prop !== "constructor") { | |
hash[prop] = Object.getOwnPropertyDescriptor(clazz.prototype, prop).value; | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.IndexRoute = Ember.Route.extend({ | |
viewName: "foo" | |
}); | |
App.FooView = Ember.View.extend({ | |
didInsertElement: function() { | |
console.log("FooView") | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App = Ember.Application.create(); | |
var html = $("#myTemplate").remove().html(); | |
var template = Ember.Handlebars.compile(html); | |
var model = "Click here"; | |
var controller = { model: model }; | |
var view = Ember.View.create({ | |
template: template, |
NewerOlder