Skip to content

Instantly share code, notes, and snippets.

View TheLarkInn's full-sized avatar
🦀
Getting Rusty

Sean Larkin TheLarkInn

🦀
Getting Rusty
View GitHub Profile
@TheLarkInn
TheLarkInn / gist:8483197
Created January 17, 2014 22:54
anotherCrash.crash
Code Type: X86-64
Parent Process: launchd [267]
Date/Time: 2014-01-17 12:19:44.322 -0800
OS Version: Mac OS X 10.9.1 (13B42)
Report Version: 7
Call graph:
96 Thread_195178 DispatchQueue_1: com.apple.main-thread (serial)
+ 96 start (in libdyld.dylib) + 1 [0x7fff871235fd]
@TheLarkInn
TheLarkInn / gist:8527422
Created January 20, 2014 19:32
convert all strings to utf8
hash.map{ |row|
row.keys.each{|key|
puts "data for #{key} has been converted to utf8"
row[key] = row[key].to_utf8 if row[key].class == String
}
row
}
@TheLarkInn
TheLarkInn / app.rb
Created January 21, 2014 14:04
Appointments is a class declared in my Sinatra app, its used to query my db using Sequel based upon the parameters that are given. I want to be able to have either 0 or 6 parameters and dynamically make the query reflect that. The second file is the route where the class method is called, I format the hash before hand so I can take the key and v…
get '/tt_pt_api/api/v1/appointments' do
params_hash = {
"appointment.ticket_id" => params[:ticket_id],
"u_user.user_id" => params[:user_id],
"account.serial_num" => params[:serial_num],
"appointment.appointment_type_id" => params[:appointment_type_id]
}
data = Appointments.appointments_with_params(params[:start_date], params[:end_date], params_hash)
@TheLarkInn
TheLarkInn / gem env output
Created January 24, 2014 12:37
gem env output
sean:tt_project_tracker_api_beta sean$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.1
- RUBY VERSION: 2.1.0 (2013-12-25 patchlevel 0) [x86_64-darwin12.0]
- INSTALLATION DIRECTORY: /Users/sean/.rvm/gems/ruby-2.1.0
- RUBY EXECUTABLE: /Users/sean/.rvm/rubies/ruby-2.1.0/bin/ruby
- EXECUTABLE DIRECTORY: /Users/sean/.rvm/gems/ruby-2.1.0/bin
- SPEC CACHE DIRECTORY: /Users/sean/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
@TheLarkInn
TheLarkInn / ruby app.rb output
Created January 24, 2014 12:40
ruby app.rb output
sean:tt_project_tracker_api_beta sean$ ruby app.rb
== Sinatra/1.4.4 has taken the stage on 80 for development with backup from Thin
>> Thin web server (v1.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on localhost:80, CTRL+C to stop
>> Stopping ...
== Sinatra has ended his set (crowd applauds)
/Users/sean/.rvm/gems/ruby-2.1.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:526:in `start_tcp_server': no acceptor (port is in use or requires root privileges) (RuntimeError)
from /Users/sean/.rvm/gems/ruby-2.1.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:526:in `start_server'
from /Users/sean/.rvm/gems/ruby-2.1.0/gems/thin-1.5.1/lib/thin/backends/tcp_server.rb:16:in `connect'
@TheLarkInn
TheLarkInn / webviewpopup.m
Created February 10, 2014 12:36
Singleton/sorta/sharedInstance
+(WebViewPopup*)sharedWebViewPopup
{
static dispatch_once_t once;
static WebViewPopup* sharedWebViewPopup;
dispatch_once(&once, ^{
sharedWebViewPopup = [[WebViewPopup alloc] init];
});
return sharedWebViewPopup;
}
<script type="text/ng-template" id="one.html">
<div>This is first template</div>
</script>
<script type="text/ng-template" id="two.html">
<div>This is second template</div>
</script>
(function () {
var root = angular.element(document.getElementsByTagName('body'));
var watchers = [];
var f = function (element) {
angular.forEach(['$scope', '$isolateScope'], function (scopeProperty) {
if (element.data() && element.data().hasOwnProperty(scopeProperty)) {
angular.forEach(element.data()[scopeProperty].$$watchers, function (watcher) {
watchers.push(watcher);
@TheLarkInn
TheLarkInn / watchEvaluation.js
Created January 28, 2015 14:02
Example of Using $scope.$watch to watch the evaluative value of a function
$scope.$watch(
function () { return obj.hasOwnProperty("choice") },
function (newLocation, oldLocation) {
//Do things here.
}
);
@TheLarkInn
TheLarkInn / convertES6StyleAndHTMLImportsToTypeScriptFriendlyRequires.js
Created April 13, 2016 20:18
convertES6StyleAndHTMLImportsToTypeScriptFriendlyRequires.js
module.exports = function convertES6StyleAndHTMLImportsToTypeScriptFriendlyRequires(source) {
this.cacheable && this.cacheable();
var hasES6StyleAndHTMLImportRegex = new RegExp(/import\s+(.+)\s+from\s+([\'|\"].+\.(html|jade|haml|twig|erb|css|scss|less|yaml|sass|styl)[\'\"]);?/, 'g');
var results;
try {
results = source.replace(hasES6StyleAndHTMLImportRegex,
"let $1 = require($2);\n"
);