Skip to content

Instantly share code, notes, and snippets.

View thejchap's full-sized avatar

justin thejchap

View GitHub Profile
described_class.name.underscore.split('_').reverse.drop(1).reverse.join('_').to_sym
query: function (str, opts) {
var def = new Deferred();
request.get(this.target, { query: opts }).then(function (res) {
def.resolve(res.vals);
}, def.reject);
return QueryResults(def);
}
import Ember from 'ember';
export default Ember.ArrayController.extend({
/**
* @return {Ember.ArrayProxy}
*/
completeTasks: Ember.computed.filterBy("model", "isComplete"),
/**
* @return {Ember.ArrayProxy}
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk
sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -rf /Library/LaunchAgents/com.oracle.java.Java-Updater.plist
sudo rm -rf /Library/PrivilegedHelperTools/com.oracle.java.JavaUpdateHelper
sudo rm -rf /Library/LaunchDaemons/com.oracle.java.JavaUpdateHelper.plist
sudo rm -rf /Library/Preferences/com.oracle.java.Helper-Tool.plist
@thejchap
thejchap / checkout.js
Last active August 22, 2018 21:34
Checkout
class Checkout extends Component {
constructor(props) {
super(props);
this.subscriptions = [];
}
componentDidMount() {
const { cardReader: { emitter } } = global;
@thejchap
thejchap / cardreadermanager.swift
Created August 22, 2018 21:38
cardreadermanager.swift
@objc(CardReaderManager)
class CardReaderManager: RCTEventEmitter {
func cardDataReceived(data: Dictionary<String, String>, sender: AnyObject) {
StripeUtil.createToken(data) { (token, error) in
self.sendEvent(
withName: "stripeToken",
body: token
)
}
}
@thejchap
thejchap / checkout.js
Created August 22, 2018 21:52
checkout
export default Component.extend({
didInsertElement() {
document.addEventListener('message', this._handleMessage.bind(this));
},
willDestroyElement() {
document.removeEventListener('message', this._handleMessage.bind(this));
}
_handleMessage(message) {
@thejchap
thejchap / rule90.py
Created November 26, 2019 18:44
Rule 90 Implementation
#!/usr/bin/env python3
"""
rule 90 implementation
"""
def rule90(starting):
grid, m = [starting], len(starting)
for i in range(1, m):
@thejchap
thejchap / misort.py
Last active June 13, 2020 19:01
misort.py
"""
https://en.wikipedia.org/wiki/Merge-insertion_sort
"""
from typing import List, Callable, Tuple
from bisect import bisect
# max of pair, min of pair
Pair = Tuple[int, int]
@thejchap
thejchap / jdb_transaction.py
Last active October 8, 2020 15:31
jdb_transaction.py
from jdb.db import DB
db = DB()
with db.transaction() as txn:
 txn.read(b'foo')
 txn.write(b'bar', b'baz')