Skip to content

Instantly share code, notes, and snippets.

View atleastimtrying's full-sized avatar

Anders Fisher atleastimtrying

View GitHub Profile
step 1
change things on your branch,
commit them with a sensible name on your branch.
step 2
switch to master,
pull from origin, merge where needed.
step 3
switch to your branch
@blah =
one: 1
two: 2
add_more_blah = (@blah)->
{
one: @blah.one
two: @blah.two
three: 3
four: 'why not have a string?'
[1] pry(#<LogoQuestion>)> url
=> "https://quizall_assets.s3.amazonaws.com/logo_questions/logos/000/000/001/original/shell.png?1412259727"
[2] pry(#<LogoQuestion>)> open(url,&:read)
URI::InvalidURIError: the scheme https does not accept registry part: quizall_assets.s3.amazonaws.com (or bad hostname?)
from /Users/anders/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/uri/generic.rb:214:in `initialize'
[3] pry(#<LogoQuestion>)>
@atleastimtrying
atleastimtrying / example.json
Created October 1, 2014 16:04
base64 example
{"categories":["Sport","Animals","Geography"],"levels":["Level1","Level2","Level3"],"items":[{"id":"logo_question 1","question":"Question for level Level1, category Sport, with the logo id of 1","answer":{"id":4,"logo_question_id":1,"answer":"true","created_at":"2014-10-01T14:49:39.985Z","updated_at":"2014-10-01T14:49:39.985Z"},"hints":["sample hint"],"options":["false","false","false","true"],"src":"data:image/png;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAICAgICAQICAgIDAgIDAwYEAwMD AwcFBQQGCAcJCAgHCAgJCg0LCQoMCggICw8LDA0ODg8OCQsQERAOEQ0ODg7/ 2wBDAQIDAwMDAwcEBAcOCQgJDg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4O Dg4ODg4ODg4ODg4ODg4ODg4ODg4ODg7/wAARCAHgAoADASIAAhEBAxEB/8QA HgAAAQQDAQEBAAAAAAAAAAAABgMEBQcBAggACQr/xABIEAABAwIEAwYDBgUD AwMDAwUBAgMRAAQFEiExBkFRBxMiYXGBFDKRI0KhscHwCBVS0eEzYvEWJHJD U4IXNJIYJaJjc5Oy0v/EABwBAAIDAQEBAQAAAAAAAAAAAAMEAQIFBgAHCP/E ADkRAAICAQMDAwEHAwMEAQUAAAABAhEDBBIhBTFBEyJRYQYycYGRodEUFbFC 4fAjM2LBQyRSU5Lx/9oADAMBAAIRAxEAPwD5mIB+8SJNb5TMSCB51rEAqVqZ 0PXfSlEkhMjTqI+tc22b7FhGUEJ1OhPWvLTCDkG596wCMs7ka
@atleastimtrying
atleastimtrying / example.rb
Created September 23, 2014 10:38
a while?
I need 100 usernames some may fail the test
def get_usernames
response = []
#loop
name = random_name()
response << random_name unless User.find(username: name)
#end loop
response
end
@atleastimtrying
atleastimtrying / image_download.js
Created September 9, 2014 16:09
attempt at accesing a directory in phonegap 3.5 using phonegap developer app on a nexus 5.
(function(){
window.onerror = function(err,fn,ln) {
alert("ERROR:" + err + ", " + fn + ":" + ln);
};
window.namespace.ImageDownload = function(){
$('#test').click(function(event){
event.preventDefault();
get_fs(function(fs){
var directory = 'sample';
fs.root.getDirectory(directory, {
@atleastimtrying
atleastimtrying / get_category.js
Created September 4, 2014 10:44
how to get a game up and running via events in quizall for logos
$(quizall).trigger('category_levels_choice',{
game: 'logos_questions',
callback: function(category, level){ console.log(category, level); }
});
@atleastimtrying
atleastimtrying / hints.js
Created September 2, 2014 14:59
sample of adding indexs to a mustache template
var hints = [ 'hint1', 'hint two', 'hint three', 'hint 4' ];
var hints_with_ids = hints.map(function(hint, index){
return { name: 'hint' + index, hint: hint } ;
});
$(quizall).trigger('get_categories', {
game: 'true_false',
complete: function(categories){
//do something with categories here
}
});
@atleastimtrying
atleastimtrying / post_score_example.js
Created August 20, 2014 13:09
internal score events api
$(quizall).trigger('post_score', {
game: 'true_false',
level: 'Level1',
score: 100,
complete: function(options){
if(options.success !== true){
//provide answer via options.details
}
if(options.location === 'local'){
//redirect to whichever page you like