Skip to content

Instantly share code, notes, and snippets.

View meltingice's full-sized avatar

Ryan LeFevre meltingice

View GitHub Profile
@meltingice
meltingice / grail14.js
Last active August 9, 2023 16:07
Grail #14
// Utility function for shuffling an array
const shuffle = a => a.sort(() => Math.random() - 0.5)
// The current day of the week (0 = Sunday, 1 = Monday, etc.)
const cId = new Date().getDay()
// The set of symbols used for each day of the week
const cs = [
['🔳', '🟦', '🔲', '🟥'], // Sunday
@meltingice
meltingice / gist:2171421
Created March 23, 2012 14:53
CamanJS Example
// First, initialize Caman (only do this once)
caman = Caman("#image-id");
// This will be called when a slider is adjusted
var applyFilters = function () {
// Revert the canvas to its original state. This is asynchronous.
caman.revert(function () {
// Once canvas is ready, go through each slider and call filter
var slider;
for (var key in sliders) {
@meltingice
meltingice / usernode.php
Created November 15, 2010 03:15
Social graph functions implemented using Redis.
<?
/*
* This example would probably work best if you're using
* an MVC framework, but it can be used standalone as well.
*
* This example also assumes you are using Predis, the excellent
* PHP Redis library available here:
* https://github.com/nrk/predis
*/
// In the TypeTool, the StyleRun defines all of the different styles
// that are applied to a text layer. Each style is defined in the RunArray,
// and the character indices for each style is defined in the RunLengthArray,
// i.e. the first style exists for 7 characters, the 2nd for 7 characters,
// and the third for 10 characters.
> typeTool.engineData.EngineDict.StyleRun
{ DefaultRunData: { StyleSheet: { StyleSheetData: {} } },
RunArray:
[ { StyleSheet: [Object] },
{ StyleSheet: [Object] },
[2018-03-01 11:17:26.549751]: While bootstrappping, fork between our block: D2AFFA6D4205258374F7B38CDAE9FAFA76D3905789818F339676A099D3C9817A and block 1A0E6679E59783E35295DEE23D0CB253F3D52F7FDFE7C6C4A7A7245C32929801 both with root 8F1FD01CD1407521F24AC315681DA5826D4D931A4EDA58E74F444B413AF170B8
[2018-03-01 11:17:58.762764]: While bootstrappping, fork between our block: 0978DE900C7B354122235C8C20BB4C0F9D8CE065B1EBBBC7AFD94FBD468E81BE and block F6B57FB5F1EF5D2919FB31454136D0A0EA7D000A73BEC603B8ECDBD36ADAB33B both with root EDE639C142DD851E4D162791DC7D803BDEA13A2EF53D7ED166DCD81DB4CD4239
[2018-03-01 11:18:00.986386]: While bootstrappping, fork between our block: 41C73322F0BF8513A16EAF75AE15CE7DB6F79CF98982C2C389EF1E1E2B03B652 and block CEC34C0D90E9AA43A833AB03103819970B2757B0DC7DE2A09206EBF1EB438E64 both with root 9B61AB4AAA741E9D395BB840951D81B5D1EB7B221FA857463DDB0D68A835F066
[2018-03-01 11:18:04.946908]: While bootstrappping, fork between our block: 7B9395B1144059204095138B9335CE192B1BBB14223734AB4FD284DE9D08
@meltingice
meltingice / metadata.xml
Created December 26, 2013 06:05
Sony DSC-QX10 raw DNLA stream. I believe it transmits image data in JPEG form.
<root xmlns="urn:schemas-upnp-org:device-1-0" xmlns:dlna="urn:schemas-dlna-org:device-1-0" xmlns:av="urn:schemas-sony-com:av">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<device>
<dlna:X_DLNADOC xmlns:dlna="urn:schemas-dlna-org:device-1-0">DMS-1.50</dlna:X_DLNADOC>
<deviceType>urn:schemas-upnp-org:device:MediaServer:1</deviceType>
<friendlyName>DSC-QX10</friendlyName>
<manufacturer>Sony Corporation</manufacturer>
@meltingice
meltingice / application.rb
Created April 22, 2014 13:15
Add user ID to Rails logs with log tags and Authlogic
MyApp::Application.configure do
config.log_tags = [UserLogger.get]
end
@meltingice
meltingice / README.md
Created June 29, 2017 19:02
AWS Lambda Deploy Script

Project Structure

Put all of your application code (including your package.json and node_modules folder) into a folder in this directory named Package. The entry point is Package/index.js.

Getting Started

  1. Install AWS CLI
    • brew install awscli
  2. Configure AWS CLI
    • aws configure --profile [name of your project]
  • AWS Access Key ID: [paste-access-key-id-here]
def member_is_blocking?(other_member)
blocked_member_ids.include?(other_member['id'])
end
def blocked_member_ids
return [] if @current_member.nil?
@blocked_member_ids ||= @current_member.blocked_members.pluck(:id)
end
def member_has_voted?(comment)
# We create an index to store all of the comments in the tree,
# indexed by ID. This lets us quickly build out the comment structure
# as we iterate over each comment.
node_index = ActiveSupport::OrderedHash.new
nodes.each do |node|
node_index[node.id] = {
node: node,
parent: nil,
reply_to: nil,
children: []