Skip to content

Instantly share code, notes, and snippets.

View samanthamjohn's full-sized avatar

Samantha samanthamjohn

View GitHub Profile
@samanthamjohn
samanthamjohn / index.html
Created February 2, 2019 00:23
PIXI canvas memory leak
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pixi.js/4.5.1/pixi.min.js"></script>
<script src="index.js"></script>
</head>
<body>
</body>
</html>
comment = "# frozen_string_literal: true\n"
filemode = "r+"
dirs = Dir[Rails.root.join('spec/**/*.rb').to_s] + Dir[Rails.root.join('lib/**/*.rake').to_s] + Dir[Rails.root.join('lib/**/*.rb').to_s]
dirs.each do |filename|
contents = File.open(filename, "r") do |f|
f.read
end
contents = comment + contents
@samanthamjohn
samanthamjohn / hopscotch_blocks.h
Created March 16, 2017 20:46
All the blocks used in Hopscotch
// These are mappings of numbers to actual types that we use in Hopscotch.
// Default is to start at 0 and add 1 to the previous number unless explicitly set to something else.
typedef NS_ENUM(NSInteger, HSBlockType) {
HSBlockTypeNone = 22,
HSBlockTypeMove = 23,
HSBlockTypeRotate = 24,
HSBlockTypeChangeX = 27,
HSBlockTypeChangeY = 28,
HSBlockTypeScale = 29,
@samanthamjohn
samanthamjohn / parsing.md
Last active February 28, 2017 13:54
Hopscotch Project structure

How to parse

  1. Add all the globalVariables to the scope.
  2. Add all the instanceVariables to the object prototype.
  3. Add all the objects to the scope.
  4. Add all the abilities to the scope.
  5. Add all the scenes to the scope.
@samanthamjohn
samanthamjohn / project_structure
Created June 30, 2015 18:01
Dream project structure for Hopscotch
{
"project_object_ids" : {
"object_ids" : [],
"block_ids" : {
"script_block_ids" : [1, 2, 3, 5],
"parameter_blocks" : []
},
"rule_ids" : [],
"script_ids" : {
@samanthamjohn
samanthamjohn / generate_hopscotch_project
Created May 1, 2015 14:04
Generates a hopscotch project with 500 objects all growing, modify as needed for your own projects
class ProjectMaker
def original_json
'{
"rules" : [
{
"objectID" : "966281C2-C13C-4CC0-9E5E-00A2CF1D363C-28679-00001DADC7E1BB63",
"abilityID" : "0C0AC15D-34D4-4411-AE82-0B1FE1B85D49-28679-00001DADC7E4CA0B",
"parameters" : [
{
"type" : 42,
@samanthamjohn
samanthamjohn / user-appreciation
Created February 4, 2015 22:11
User Appreciation Stats
def find_projects(date_str)
start_date = Date.parse(date_str)
end_date = start_date + 1.month
Project.published.filtered.where("created_at > ? AND created_at <= ?", start_date, end_date)
end
def has_thing(project, method)
project.send(method).present? && project.send(method) > 0
end
@samanthamjohn
samanthamjohn / print_has_been_played.rb
Last active August 29, 2015 14:13
A script for finding what percentage of projects are liked/starred/etc
Category.all.each do |c|
has_been_played = c.projects.where("has_been_removed IS NOT TRUE AND play_count > 0").count
all_projects = c.projects.where("has_been_removed IS NOT TRUE").count
ratio = has_been_played.to_f/all_projects.to_f
puts "#{c.label} has #{ratio*100} percent played"
has_been_starred = c.projects.where("has_been_removed IS NOT TRUE AND stars_count > 0").count
@samanthamjohn
samanthamjohn / print_has_been_played
Created January 8, 2015 21:04
A script for finding what percentage of projects are liked/starred/etc
categories = Category.all
categories.each do |c|
has_been_played = c.projects.where("has_been_removed IS NOT TRUE AND play_count > 0").count
all_projects = c.projects.where("has_been_removed IS NOT TRUE").count
ratio = has_been_played.to_f/all_projects.to_f
puts "#{c.label} has #{ratio*100} percent played"
has_been_starred = c.projects.where("has_been_removed IS NOT TRUE AND stars_count > 0").count
@samanthamjohn
samanthamjohn / gist:2d854331eb8cec70d82d
Last active August 29, 2015 14:09 — forked from ashaegupta/gist:3417edaf4e72d255affb
Finding number of projects that are levels
def query_for_terms(terms)
query = ""
terms.each do |term|
query += "lower(substring(title from 0 for 30)) LIKE '%#{term}%' OR "
end
query.chomp("OR ")
end
def projects_arel(weeks_ago)