Skip to content

Instantly share code, notes, and snippets.

myApp.factory('dataThing',function($q,$http){
var thatData = null;
return {
getData : function(){
//create a promise
var deferredData = $q.defer()
innitApp.provider('API',function(){
//temp storage for new collection
var _collections = []
//holds model references
var _models = {}
return {
//this fires when the provider is injected
$get : ['$resource',function($resource){
anonymous
anonymous / gist:8656313
Created January 27, 2014 20:12
squarez
int samplesPerFrame = 32;
int numFrames = 48;
float shutterAngle = .8;
int[][] result;
float time;
void draw() {
for (int i=0; i<width*height; i++)
for (int a=0; a<3; a++)
result[i][a] = 0;
@walidvb
walidvb / _requestPermissions_example.js
Last active November 13, 2019 21:25
This allows displaying a dialog to the user before actually requesting permissions from the OS. Ultimately, it allows to request that permission multiple times, which iOS prevents
import requestPermissions from './requestPermissions'
requestPermission(pickFromCamera, {
permissionNames: ['CAMERA', 'CAMERA_ROLL'],
alertTitle: '📷Camera📸',
alertBody: 'Use your camera now.',
})
// Only request every n times this is run
@walidvb
walidvb / Gemfile
Created May 20, 2016 16:23
RailsAdmin config for translatable models
#### I18n
gem 'rails-i18n', '~> 4.0.0'
gem 'globalize'
gem 'rails_admin', github: 'sferik/rails_admin'
gem 'rails_admin_globalize_field'
@walidvb
walidvb / count_database_rows.rb
Created September 2, 2021 14:01
Count all rows from all tables on rails
class DatabaseReport
def entry_counts
tables = table_model_names.map do |model_name|
entity = model_name.constantize rescue nil
next if entity.nil?
[entity.to_s, entity.count]
end.compact
total = tables.reduce(0) do |acc, curr|
puts "#{curr[0]}: #{curr[1]}"
acc + curr[1]
@ascot21
ascot21 / active_admin.js
Created January 6, 2014 03:44
Inline Editing in ActiveAdmin with Best In Place Gem
//= require jquery
//= require best_in_place
//= require jquery.purr
//= require active_admin/base
$(document).ready(function() {
$(".best_in_place").best_in_place()
$('.best_in_place').bind("ajax:success", function () {$(this).closest('tr').effect('highlight'); });
$(document).on('best_in_place:error', function(event, request, error) {
@jgarber
jgarber / MIT-LICENSE.txt
Created April 4, 2012 14:57
Responsive video
Copyright (c) 2011 ZURB, http://www.zurb.com/
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
<!doctype html>
<!-- http://taylor.fausak.me/2015/01/27/ios-8-web-apps/ -->
<html>
<head>
<title>iOS 8 web app</title>
<!-- CONFIGURATION -->