Skip to content

Instantly share code, notes, and snippets.

View NuckChorris's full-sized avatar

Peter Lejeck NuckChorris

View GitHub Profile
<?php
include_once 'classes/db.class.php';
/**
* This is an ORM.
* I may have gone a bit overboard on this final project.
* I just got tired of constantly dropping into raw SQL for mundane crap.
*/
class Model {
private $_attributes = array();
@NuckChorris
NuckChorris / contracts.js.es6
Last active August 29, 2015 14:16
Contracts implemented in ~25 LOC
/*
* Released under the MIT License
*
* Copyright (c) 2014 Peter Lejeck
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
class Anime
pg_search_scope :search,
against: { title: 'A', alt_title: 'A', synopsis: 'C' },
using: {
tsearch: {
prefix: true,
# Normalize to string length and scale to 0..1
normalization: 32,
dictionary: 'english'
},
  • Ember: See if we can simplify StoryController#isOnGroupPage
  • Ember: Clarify Story#canDeleteStory's conditional
  • Ember: Nuke group management page and replace with button to delete group (for site admins)
  • Ember: Remove all remaining references to group.closed
  • CSS: Rename community-widget.css.scss to dashboard-widgets.css.scss
  • Rails: Change Paperclip URL scheme to /group_avatar/:group_id.:ext
  • Rails: Change GroupMember#update_counter_cache! to use atomic incr/decr
  • Rails: Deduplicate Trending systems
  • Rails: Add pg_search to groups
  • Rails: Remove group_members index on group_id
@NuckChorris
NuckChorris / array.js
Last active February 12, 2018 19:47 — forked from pixelhandler/transforms.js
In Ember-CLI, transforms are located in app/transforms/name.js
// app/transforms/array.js
import Ember from 'ember';
import DS from 'ember-data';
export default DS.Transform.extend({
deserialize: function(value) {
if (Ember.isArray(value)) {
return Ember.A(value);
} else {
return Ember.A();

Here's how it's going to look like from the end user perspective:

1 hour before my PRO membership ends, if I am on a recurring plan Hummingbird will try to charge my credit card. If it succeeds everything is good. If it fails my subscription will run out and Hummingbird will try to charge my credit card again tomorrow, 3 days from now and 5 days from now. I will receive an email from Hummingbird if the charge is successful, and a different email every time charging my card fails.

{
"pack": {
"hira-vowels": {
"name": "Vowels",
"cards": [
{ "id": "e", "front": "え", "back": "e" },
{ "id": "a", "front": "あ", "back": "a" },
{ "id": "i", "front": "い", "back": "i" },
{ "id": "o", "front": "お", "back": "o" },
{ "id": "u", "front": "う", "back": "u" }
<?xml version="1.0" encoding="utf-8" ?>
<GameState xmlns="http://static.plejeck.com/apps/lurn/gamestate.xsd">
<Pack id="hiragana-basic">
<Card id="hira-vowels:e" value="12314" />
<Card id="hira-vowels:a" value="43142" />
</Pack>
<Setting id="flipped" value="true" />
<Setting id="timer" value="true" />
<Setting id="adaptive-timer" value="true" />
<State id="deck" value="hiragana-basic:hira-vowels,hiragana-basic:hira-k" />
desc "Bulk import info from TVDB"
task :bulk_import_tvdb, [:shows] => [:environment] do |t, args|
require 'parallel'
ActiveRecord::Base.connection_pool.disconnect!
config = ActiveRecord::Base.configurations[Rails.env]
config['pool'] = 20
ActiveRecord::Base.establish_connection(config)
# This fixes some threaded autoloading issues
require 'oj'
class HummingbirdListImport
include Enumerable
# Most ListImport systems shouldn't need a `list` parameter, since they separate manga and anime
# exports. We do, since our backups contain your whole library.
def initialize(str, list)
@list = Oj.load(str)[list.to_s]
# The class of the database we're matching against