Skip to content

Instantly share code, notes, and snippets.

require 'bundler/setup'
Bundler.require
module Soshified
def self.setup!
config = YAML.load_file(File.join(File.dirname(__FILE__), 'config/db.yml'))
DataMapper::Logger.new(STDOUT, :debug)
DataMapper.setup(:default, config['ipgallery'])
end
@gmanley
gmanley / gist:3555759
Created August 31, 2012 16:51
Date Regex
date = '03/27/1992'
year = /(?<year>(20)?(07|08|09|10|11|12))/
month = /(?<month>0[1-9]|1[012])/
day = /(?<day>0[1-9]|\.[1-9]|[12][0-9]|3[01])/
NUMERAL_DATE_REGEX = /#{year}(?<separator>\.|\-|\/|_)?#{month}(\k<separator>)?#{day}/
if match = NUMERAL_DATE_REGEX.match(@file_name)
Date.parse(date).strftime("%y.%m.%d")
end
@gmanley
gmanley / gist:3710063
Created September 12, 2012 21:29
Dtrace msyql
sudo dtrace -qn 'pid$target:mysqld:*mysql_parse*:entry { printf("%Y %s\n", walltimestamp, copyinstr(arg1)) }' -p `pgrep -x mysqld`
---
libmpcodecs/vf_lavc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libmpcodecs/vf_lavc.c b/libmpcodecs/vf_lavc.c
index b2c1dd7..0ce98c0 100644
--- a/libmpcodecs/vf_lavc.c
+++ b/libmpcodecs/vf_lavc.c
@@ -76,7 +76,7 @@ static int config(struct vf_instance *vf,
return 0;
// While you can edit this file, it's best to put your changes in
// "User/Preferences.sublime-settings", which overrides the settings in here.
//
// Settings may also be placed in file type specific options files, for
// example, in Packages/Python/Python.sublime-settings for python files.
{
// Sets the colors used within the text area
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
// Note that the font_face and font_size are overriden in the platform
<?php
/*
* jQuery File Upload Plugin PHP Class 6.1
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
@gmanley
gmanley / gist:4657954
Last active December 20, 2016 17:10
Random avatar in plug.dj every 5 seconds.
(function randomAvatar() {
var userPoints = parseInt($('#user-points-value').text().replace(',', ''));
var avatars = [];
$.each(AvatarOverlay.avatarSets[0], function(i, value) {
if (value.required <= userPoints) {
avatars = avatars.concat(value.avatars);
};
});
@gmanley
gmanley / backtrace.log
Created February 14, 2013 09:39
sidekiq & zipruby segmentation fault info
2013-02-12T06:24:41Z 32462 TID-efyw0 AlbumArchiver JID-c3214393a6220b454bd095a9 INFO: start
/u/apps/example.com/releases/20130212062332/app/models/archive.rb:20: [BUG] Segmentation fault
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0033 p:---- s:0124 b:0124 l:000123 d:000123 CFUNC :open
c:0032 p:0182 s:0119 b:0119 l:0018d8 d:0018d8 METHOD /u/apps/example.com/releases/20130212062332/app/models/archive.rb:20
c:0031 p:0113 s:0114 b:0114 l:000113 d:000113 METHOD /u/apps/example.com/releases/20130212062332/app/workers/album_archiver.rb:14
c:0030 p:0025 s:0107 b:0107 l:000e30 d:000106 BLOCK /u/apps/example.com/shared/bundle/ruby/1.9.1/gems/sidekiq-2.7.2/lib/sidekiq/processor.rb:45
c:0029 p:---- s:0105 b:0105 l:000104 d:000104 FINISH
class Person
# extend and include go first
extend SomeModule
include AnotherModule
# constants are next
SOME_CONSTANT = 20
# afterwards we have attribute macros
attr_reader :name
@gmanley
gmanley / gist:5102114
Last active December 14, 2015 14:39
Quickly Host a Git Repository
# **Quickly Host a Git Repository**
REPO_ROOT='~/source/repos' # Can be anywhere
GIT_PROJECT_PATH='~/projects/my_cool_git_project' # Your local project using git
GIT_PROJECT_NAME=$(basename $GIT_PROJECT)
mkdir -p $REPO_ROOT
cd $REPO_ROOT
git clone --bare $GIT_PROJECT_PATH
cd $GIT_PROJECT_NAME.git