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
$ jruby -e "require 'uglifier'; Uglifier.compile File.read 'jquery-1.7.1.js'" | |
java(25487,0x10f18a000) malloc: *** error for object 0x7f9604a05300: pointer being freed was not allocated | |
*** set a breakpoint in malloc_error_break to debug | |
Abort trap: 6 |
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
require 'rack' | |
require 'json' | |
require 'torquebox-messaging' | |
class EventStream | |
def self.call(env) | |
path = Rack::Utils.unescape env["PATH_INFO"] | |
[200, { | |
'Content-Type' => 'text/event-stream', | |
'X-Accel-Buffering' => 'no', |
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 TORQUEBOX_HOME=/opt/torquebox-current | |
export JBOSS_HOME=$TORQUEBOX_HOME/jboss | |
export JRUBY_HOME=$TORQUEBOX_HOME/jruby | |
export PATH=$JRUBY_HOME/bin:$PATH | |
export JRUBY_OPTS='--1.9 -J-Xmx64m' | |
export JAVA_OPTS='-Xmx256m -Xms32m' |
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
#!/bin/bash | |
LANG='C' | |
cat /dev/urandom|tr -dc "a-zA-Z0-9"|fold -w 64|head |
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
require 'sprockets' | |
require 'pathname' | |
require 'uri' | |
module Sprockets | |
class UrlRewriter < Processor | |
def evaluate(context, locals) | |
rel = Pathname.new(context.logical_path).parent | |
data.gsub /url\(['"]?([^\s)]+\.[a-z]+)(\?\d+)?['"]?\)/ do |url| | |
return url if URI.parse($1).absolute? |
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
[HttpPost] | |
public ActionResult Create(int id, Projekt model) | |
{ | |
var p = db.Get<Projekt>(id); | |
if (p.Typ1Validering) | |
if (string.IsNullOrEmpty(model.Field)) | |
ModelState.AddModelError("Field", "Fältet får inte vara tomt"); | |
if (ModelState.IsValid) | |
{ |
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
require 'aws/s3' | |
require 'heroku' | |
require 'heroku/command' | |
require 'heroku/command/auth' | |
require 'heroku/command/pgbackups' | |
task :cron do | |
class Heroku::Auth | |
def self.client | |
Heroku::Client.new ENV['heroku_login'], ENV['heroku_passwd'] |
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 Entity | |
include DataMapper::Resource | |
property :enum_property, Enum[:a, :b, :c] | |
end | |
Entity.enum_property.options[:flags] #=> [:a, :b, :c] | |
# or | |
Entity.enum_property.flag_option.values #=> [:a, :b, :c] |
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
public class AutocompleteController : Controller | |
{ | |
private readonly IRepository db; | |
public AutocompleteController(IRepository db) | |
{ | |
this.db = db; | |
} | |
public JsonResult Users(string term) | |
{ |
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
protected void Application_Error(object sender, EventArgs e) | |
{ | |
var error = Server.GetLastError(); | |
var log = LogManager.GetLogger(GetType()); | |
var msg = string.Format("\r\nPath: {0}\r\nMethod: {4}\r\nUser: {1}\r\nForm: {2}\r\nReferer: {3}", | |
Request.Url, | |
User.Identity.Name, | |
Request.Form, | |
Request.UrlReferrer, | |
Request.HttpMethod); |