Skip to content

Instantly share code, notes, and snippets.

View sammynave's full-sized avatar
🤷‍♂️
🤷‍♂️

sammy nave sammynave

🤷‍♂️
🤷‍♂️
View GitHub Profile
@sammynave
sammynave / machine.js
Last active April 22, 2021 20:04
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@sammynave
sammynave / machine.js
Created March 13, 2021 20:06
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@sammynave
sammynave / machine.js
Created March 9, 2021 19:11
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
def self.enqueue_challenge_assignments(options, queued_ids, batch_size = 100)
high = JobBatcher.new(batch_size) { |batch| Resque.enqueue(ResqueJobs::HighPriorityChallengeAssignmentJob, options[:sent_on], batch, true) }
normal = JobBatcher.new(batch_size) { |batch| Resque.enqueue(ResqueJobs::ChallengeAssignmentJob, options[:sent_on], batch, true) }
$statsd.time('challenge_assignments.queuing_user_ids') do
for_each_user_needing_an_assignment(options, queued_ids) do |id, start_date, last_challenge_done_time|
notify_devs_if_error("ERROR queueing challenge assignments") do
if start_date > 1.month.ago.to_date || (last_challenge_done_time && last_challenge_done_time > 1.month.ago)
high.enqueue(id)
else
normal.enqueue(id)
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
t: task(function *() {
yield new Promise((resolve) => {
setTimeout(() => console.log('whatever'), 2000);
});
}),
cancel() {
{
"data":{
"attributes":{
"id":"80563",
"choices":[
{
"type":"ColorC",
"options":[
{
"id":"258",
// app/services/admin-check.js
import Ember from 'ember';
export default Ember.Service.extend({
isAdmin: false
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
focusedInputName: '',
actions: {
setText() {
this.set('focusedInputName', 'text');
},
unsetText() {
@sammynave
sammynave / gist:5644150
Created May 24, 2013 15:02
bind on hash change and if we are at root url, reload the page
$(window).on 'hashchange', ->
if window.location.pathname == "/"
$(window).trigger('root')
$(window).one 'root', ->
window.location.reload()