Skip to content

Instantly share code, notes, and snippets.

View spnkr's full-sized avatar

Will Jessop spnkr

  • New York, NY
View GitHub Profile
backup:
mysqldump -u [username] -p [password] [databasename] > [backupfile.sql]
compress:
mysqldump --all-databases | gzip >databasebackup.sql.gz
restore:
mysql -u [username] -p [password] [database_to_restore] < [backupfile]
restore from archive:
@spnkr
spnkr / make_cue.rb
Created April 16, 2014 09:16
plain text to .cue formatter (cue file generator)
# turns /Users/foo/cue into a real cue file called new.cue.
# /Users/foo/cue must be of format:
# start# time
# artist
# track name
#
#
#
# e.g.
# 01:15
@spnkr
spnkr / make_ui_alert_view_with_text_input
Created July 4, 2014 23:47
BW::UIAlertView with a text field, password field, or both
https://github.com/rubymotion/BubbleWrap
``` ruby
#options
opts = {
title:"A question",
message:"A description.",
buttons:["Cancel","Okay!"],
cancel_button_index:0
}
<!DOCTYPE html><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<base href="http://iosdevblog.com/tag/nsfetchedresultscontroller/"><style type="text/css">body { margin-left:0;margin-right:0;margin-top:0; }#google-cache-hdr {background:#f5f5f5 !important;font:13px arial,sans-serif !important;text-align:left !important;color:#202020 !important;border:0 !important;margin:0 !important;border-bottom:1px solid #cecece !important;line-height:16px !important ;padding:16px 28px 24px 28px !important;}#google-cache-hdr * {display:inline !important;font:inherit !important;text-align:inherit !important;color:inherit !important;line-height:inherit !important;background:none !important;border:0 !important;margin:0 !important;padding:0 !important;letter-spacing:0 !important;}#google-cache-hdr a {text-decoration:none !important;color:#1a0dab !important;}#google-cache-hdr a:hover { text-decoration:underline !important; }#google-cache-hdr a:visited { color:#609 !important; }#google-cache-hdr div { display:bl
@spnkr
spnkr / touch_id.rb
Created October 8, 2015 07:59 — forked from evansobkowicz/touch_id.rb
RubyMotion Touch ID
# Call touch_id_authenticate
def touch_id_authenticate
context = LAContext.alloc.init
auth_error = nil
reason = 'Authenticate using your fingerprint'
if context.canEvaluatePolicy(LAPolicyDeviceOwnerAuthenticationWithBiometrics, error: auth_error)
context.evaluatePolicy(LAPolicyDeviceOwnerAuthenticationWithBiometrics, localizedReason: reason, reply: lambda do |success, error|
@spnkr
spnkr / gist:a7992789aef1253cab6e
Created March 18, 2016 14:25 — forked from seanlilmateus/gist:3187192
How to use Obj-C with MacRuby/Rubymotion

Using Obj-C with MacRuby/Rubymotion

This little post aims to help you to translate Objective-C Blocks into Ruby blocks. Let's start by taking a look at few examples of iOS API call where blocks are used for animations and enumeration

Ruby Lambda Syntaxes:

Im Rubymotion and MacRuby you can use all the Ruby Lambda syntaxes that are:

block = lambda { |param|  ... }
@spnkr
spnkr / Firebase + NSAsynchronousFetchRequest.rb
Created March 26, 2016 21:14
sync coredata with firebase in rubymotion using NSAsynchronousFetchRequest. works with large data sets. uses the cdq and motion-firebase gem.
class AppDelegate
def post_messages_firebase
@_post_messages_firebase ||= "post_messages".fbase
end
end
class SomeViewController < UIViewController
def viewDidDisappear(animated=true)
super
@spnkr
spnkr / strip-emoji.rb
Created April 6, 2016 09:06 — forked from adamlwatson/strip-emoji.rb
Strip emoji
# this scrubs emoji sequences from a string - i think it covers all of them
def strip_emoji ( str )
str = str.force_encoding('utf-8').encode
clean_text = ""
# emoticons 1F601 - 1F64F
regex = /[\u{1f600}-\u{1f64f}]/
clean_text = str.gsub regex, ''
`heroku config -s | grep JAWSDB_URL >> .env`
z = `heroku config:get JAWSDB_URL`
y = z.gsub("mysql://","mysql2://")
`heroku config:set DATABASE_URL='#{y}`
@spnkr
spnkr / IRB Context
Created December 30, 2017 02:12
IRB Context
# frozen_string_literal: false
#
# irb/context.rb - irb context
# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
#
#