Skip to content

Instantly share code, notes, and snippets.

[
{
chapter_number: '1',
first_chhand_name: 'ਦੋਹਰਾ',
first_verse_number: '1'
},
{
chapter_number: '2',
first_chhand_name: 'ਚੌਪਈ',
first_verse_number: '7'
@dsomel21
dsomel21 / machine.js
Last active August 28, 2020 15:03
Generated by XState Viz: https://xstate.js.org/viz
const isUnitInStage = (context) => {
const currentStageNum = context?.schedule?.current_stage;
return context.target.stage === 'EVERY' || context.target.stage === currentStageNum;
}
const isUnitInDay = (context) => {
return context.target.day_in_stage === 'EVERY' || context.schedule.day_in_stage === context.target.day_in_stage;
}
const sendNotification = (context) => {
@dsomel21
dsomel21 / schema.js
Created February 27, 2018 03:09
Having trouble getting up and running with GraphQL... Hmmm...
const graphql = require('graphql')
const _ = require('lodash')
// I don't really know what this does tho
const {
GraphQLObjectType,
GraphQLString,
GraphQLInt,
GraphQLSchema
} = graphql
<style type="text/css">
/* Import Font */
@font-face {
font-family: "Oakes Regular";
src: url(/assets/Oakes-Regular.otf) format("truetype");
font-weight: normal;
font-style: normal;
}
@dsomel21
dsomel21 / example.cl
Created March 6, 2017 15:54
Params vs. no params
>>> $artist->fresh()->albums()->first();
string(46) "select * from "artists" where "id" = ? limit 1"
string(98) "select * from "albums" where "albums"."artist_id" = ? and "albums"."artist_id" is not null limit 1"
=> App\Album {#668
id: "1",
artist_id: "2",
album_name: "Yeezus",
created_at: "2017-03-06 15:22:37",
updated_at: "2017-03-06 15:22:37",
}
@dsomel21
dsomel21 / buy2get1free.rb
Last active August 9, 2022 12:55
Before I quit working for the Canadian Shopify Agency OnlyGrowth, the boss, James Corr from Kitchener, (who never paid me), made me write scripts.
PAID_ITEM_COUNT = 2
DISCOUNTED_ITEM_COUNT = 1
def discounted_items_to_find(total_items_seen, discounted_items_seen)
Integer(total_items_seen / (PAID_ITEM_COUNT + DISCOUNTED_ITEM_COUNT) * DISCOUNTED_ITEM_COUNT) - discounted_items_seen
end
def partition(cart, line_items)
# Sort the items by price from high to low
sorted_items = line_items.sort_by{|line_item| line_item.variant.price}.reverse
# NOTICE THIS ISN'T ALPHABETICAL
dic = {
'Colombia': [48654392, 1090909.09, 'South America'],
'China': [1339190000, 9596960.00, 'Asia']
}
target = open("save.txt", 'w')
# SORTED WILL MAKE IT ALPHABETICAL
for i in sorted(dic):
<div>
<button href="javascript:void(0)" class="nav-trigger">
<span class="menu-header-text">MENU</span>
</button>
</div>
<div class="nav-menu">
<div class="menu-items">
<ul id="MobileNav">
<div class="top_bar_search fixed-search">
<form class="search" action="/search">
@dsomel21
dsomel21 / user.js
Created September 24, 2016 22:05
Mongo user model with validation and exncryption functions
var mongoose = require('mongoose');
var bcrypt = require('bcrypt-nodejs');
var user = mongoose.Schema({
local: {
firstname: String,
lastname: String,
email: String,
password: String
},
@dsomel21
dsomel21 / passport.js
Created September 24, 2016 17:04
with mongoose and crpytion
var LocalStrategy = require('passport-local').Strategy;
var User = require('../models/user');
module.exports = function(passport){
/* SERIALIZING & DESERIALIZING USERS */
passport.serializeUser(function(user, done){
done(null, user.id);
});
passport.deserializeUser(function(id, done){