Skip to content

Instantly share code, notes, and snippets.

@lucas-clemente
lucas-clemente / gist:1835987
Created February 15, 2012 14:12
Latex wrapper for bibtex
#!/usr/bin/env ruby -w
# Save to pdflatex to ~/bin/pdflatex
if ARGV.length == 0
puts "Usage: texify <file.tex> <tex options>"
exit 1
end
file = ARGV.select{|v| v =~ /.*\.tex/}[0]
#!/usr/bin/env ruby -wKU
require 'rainbow'
def exec_cmd(cmd, ignore_fail = false)
puts cmd.bright
if !system(cmd, :out => File.open(File::NULL, 'w'))
if ignore_fail
return 1
else
@lucas-clemente
lucas-clemente / rvm.fish
Created June 11, 2012 08:29
Fix for .config/fish/functions/rvm.fish
function rvm -d 'Ruby enVironment Manager'
# run RVM and capture the resulting environment
set -l env_file (mktemp -t rvm.fish.XXXXXXXXXX)
bash -c 'source ~/.rvm/scripts/rvm; rvm "$@"; status=$?; env > "$0"; exit $status' $env_file $argv
# apply rvm_* and *PATH variables from the captured environment
and eval (grep '^rvm\|^[^=]*PATH' $env_file | sed '/^[^=]*PATH/y/:/ /; s/^/set -xg /; s/=/ /; s/$/ ;/; s/(//; s/)//')
# clean up
rm -f $env_file
@lucas-clemente
lucas-clemente / validate.rb
Created July 7, 2012 17:20
Validate all rows in a rails database
Dir['app/models/*.rb'].map {|f| File.basename(f, '.*').camelize.constantize }.map { |c| {c.name => c.all.select {|f| f.invalid?}.map {|f| f.errors}}}
@lucas-clemente
lucas-clemente / gist:3217147
Created July 31, 2012 13:45
Mathematica assumptions helper
$Assumptions = {# \[Element] Reals, # > 0} & /@ {m, k, T} // Flatten;
@lucas-clemente
lucas-clemente / gist:3811728
Created October 1, 2012 13:14
ChkTeX failed to build on 10.8.2

03.make:

Makefile:120: .ChkTeX.d: No such file or directory
Makefile:120: .FindErrs.d: No such file or directory
Makefile:120: .OpSys.d: No such file or directory
Makefile:120: .Resource.d: No such file or directory
Makefile:120: .Utility.d: No such file or directory
cc -M -I. -I. -DHAVE_CONFIG_H -DSYSCONFDIR=\"/usr/local/Cellar/chktex/1.7.1/etc\" -D__unix__ Utility.c > .Utility.d.tmp
cc -M -I. -I. -DHAVE_CONFIG_H -DSYSCONFDIR=\"/usr/local/Cellar/chktex/1.7.1/etc\" -D__unix__ Resource.c > .Resource.d.tmp
cc -M -I. -I. -DHAVE_CONFIG_H -DSYSCONFDIR=\"/usr/local/Cellar/chktex/1.7.1/etc\" -D__unix__ OpSys.c > .OpSys.d.tmp
@lucas-clemente
lucas-clemente / latex.py
Created October 2, 2012 11:51
LaTeX linter for SublimeLint
# -*- coding: utf-8 -*-
# ruby.py - sublimelint package for checking latex files
import re
from base_linter import BaseLinter
CONFIG = {
'language': 'LaTeX',
'executable': 'chktex',
@lucas-clemente
lucas-clemente / Tomorrow.tmTheme
Created October 2, 2012 12:12
Tomorrow theme + SublimeLinter
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>comment</key>
<string>http://chriskempson.com</string>
<key>name</key>
<string>Tomorrow</string>
<key>settings</key>
<array><dict><key>name</key><string>mon_color</string><key>scope</key><string>mcol_ff0000FF</string><key>settings</key><dict><key>background</key><string>#ff0000FF</string><key>caret</key><string>#FFFFFFFF</string><key>foreground</key><string>#FFFFFFFF</string></dict></dict>
server {
listen 443;
server_name example.com;
client_max_body_size 0;
chunkin on;
ssl on;
ssl_certificate /path/to/crt;
ssl_certificate_key /path/to/key;
@lucas-clemente
lucas-clemente / gist:9623826
Created March 18, 2014 16:34
convert sublime snippets to atom
require "json"
json = JSON.parse(IO.read('snippets.json'))
json.each do |s|
name = s["contents"]
prefix = s["trigger"]
body = s["contents"]
puts name.to_json
puts " 'prefix': #{prefix.to_json}"