Skip to content

Instantly share code, notes, and snippets.

View djrobby's full-sized avatar

Robby Dhillon djrobby

  • Detroit, MI - USA
View GitHub Profile
@djrobby
djrobby / keys.rb
Last active January 2, 2019 23:18 — forked from tysonmote/keys.rb
Utility functions for performing operations on large Redis keyspaces
require 'redis'
REDIS = Redis.new( url: "..." )
def each_keys_chunk( pattern = nil, &block )
opts = { count: 100 }
opts[:match] = pattern if pattern
cursor = 0
loop do
cursor, keys = REDIS.scan( cursor, opts )
@djrobby
djrobby / README.md
Created June 2, 2019 14:38 — forked from joyrexus/README.md
Vanilla JS equivalents of jQuery methods

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
// ==UserScript==
// @name Unblur scribd.com
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://vi.scribd.com/*
// @grant none
// ==/UserScript==
(function() {
@djrobby
djrobby / backup-mariadb.sh
Last active December 4, 2020 16:18 — forked from karolyi/backup-mariadb.sh
MySQL/MariaDB Backup/Restore Scripts
#!/usr/bin/env bash
mariabackup --stream=xbstream --backup --user root|pigz >mariadb-backup.gz
import Combine
import Foundation
struct NamedURL: Codable {
let name: String
let url: URL
}
struct PokeAPIResponse: Codable {
let results: [NamedURL]
@djrobby
djrobby / CombineClient.swift
Last active February 28, 2021 12:13 — forked from sarpsolakoglu/CombineClient.swift
A simple Swift 5.1 REST client that uses Combine
//
// CombineClient.swift
// CombineClient
//
// Created by Sarp Solakoglu on 14/11/2019.
// Copyright © 2019 Sarp Solakoglu. All rights reserved.
//
import Foundation
import Combine
@djrobby
djrobby / sequel_scopes.rb
Created December 18, 2020 14:34 — forked from odigity/sequel_scopes.rb
The Sequel Gem: Everything About Scopes
# (I recommend understanding the basics of this first: http://sequel.jeremyevans.net/rdoc/files/doc/object_model_rdoc.html)
# Extending the underlying dataset (http://sequel.jeremyevans.net/rdoc/files/README_rdoc.html#label-Extending+the+underlying+dataset)
# The recommended way to implement table-wide logic by defining methods on the dataset using dataset_module:
class Post < Sequel::Model
dataset_module do
def posts_with_few_comments
where{num_comments < 30}
@djrobby
djrobby / credit_card.rb
Created December 24, 2020 20:55 — forked from Talha5/credit_card.rb
Ruby - Credit Card
class CreditCard
attr_accessor :card, :store
def initialize(card_identifier)
@card = card_identifier
@store = {
amex: {begins_with: ["34", "37"], number_length: ["15"]},
discover: {begins_with: ["6011"], number_length: ["16"]},
mastercard: {begins_with: ["51","52","53","54","55"], number_length: ["16"]},
visa: {begins_with: ["4"], number_length: ["13", "16"]},
@djrobby
djrobby / icecast-kh
Last active March 25, 2021 10:45 — forked from ssamjh/icecast-kh
icecast-kh init.d Script (Ubuntu 20.04)
#!/bin/bash
### BEGIN INIT INFO
# Provides: icecast-kh
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts the icecast-kh audio streaming server daemon
### END INIT INFO
#