Skip to content

Instantly share code, notes, and snippets.

View neurodynamic's full-sized avatar
💭
GitHub still has a contract with ICE so I'm still not giving them any money.

neurodynamic neurodynamic

💭
GitHub still has a contract with ICE so I'm still not giving them any money.
View GitHub Profile
@neurodynamic
neurodynamic / index.html
Last active May 23, 2020 18:03 — forked from gaearon/index.html
Add React in One Minute
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Add React in One Minute</title>
</head>
<body>
<h2>Add React in One Minute</h2>
<p>This page demonstrates using React with no build tooling.</p>
@neurodynamic
neurodynamic / slow_array.rb
Last active October 6, 2016 13:51
Artificially slow Ruby array implementation for data structures learning
class SlowArray
def initialize(items)
operation!
@items = {}
items.each_with_index do |item, index|
@items[index] = item
end
end
@neurodynamic
neurodynamic / board.rb
Created July 12, 2016 00:32
Simple Ruby Tic Tac Toe
class Board
def initialize
@rows = three_blank_rows
end
def playable_cell?(row, col)
return false unless (1..3).cover?(row) && (1..3).cover?(col)
@rows[col - 1][row - 1] == ' '
end
@neurodynamic
neurodynamic / puts-variable.sublime-snippet
Created March 31, 2016 15:22
Sublime Text puts variable snippet
<snippet>
<content><![CDATA[
puts "${1:Output}: #{(${1:Output}).to_s}"
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>pv</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
@neurodynamic
neurodynamic / validationFunctions.js
Last active July 17, 2018 12:55
AJAX validation with redux-form example
/* EXPLANATIONS/EXAMPLES THAT MAY PROVIDE HELPFUL REFERENCE
http://erikras.github.io/redux-form/#/examples/asynchronous-blur-validation
https://github.com/erikras/react-redux-universal-hot-example/blob/b46921a990991e85522dbfc3195a46490a8f4e90/src/components/SurveyForm/SurveyForm.js
https://github.com/erikras/redux-form/issues/119
*/
// Working function with real request
export function asyncValidate (data) {
if (!data.email) {
return Promise.resolve({})
@neurodynamic
neurodynamic / pointy_progress.js
Created September 24, 2015 16:46
Arrow-based checkout progress bar css styles. CSS vendor prefixes NOT included.
$(document).ready(function(){
$("a").click(function(){
updateProgress($(this).closest('li').attr('id'));
});
});
var updateProgress = function(clickedId) {
console.log(clickedId);
var progress_nodes = $('ul.progress li');
@neurodynamic
neurodynamic / progress.css
Created September 24, 2015 01:42
Checkout progress bar css styles. Vendor prefixes NOT included in CSS.
ul.progress {
list-style: none;
margin: auto;
height: 100px;
background-color: transparent;
display: flex;
justify-content: space-between;
}
ul.progress li {
background-color: transparent;
@neurodynamic
neurodynamic / validate_uniqueness_scope.rb
Created August 5, 2015 15:19
custom scoped attribute uniqueness validation method for Volt framework
def validate_uniqueness_scope(*attribute_array)
attributes_hash = Hash[attribute_array.map { |i| [ i, send(i)] }]
store.send(self.class.name.downcase.pluralize).where(attributes_hash).count.then do |count|
if count > 0
{ self.class.name.downcase.to_sym => ["#{attributes_hash.values.join(', ')} already exists."] }
else
{}
end
@neurodynamic
neurodynamic / Capfile
Last active August 29, 2015 14:24
Files for deploying a Volt application to Digital Ocean via Intercity (files not included here need no alteration from standard Intercity setup)
# Load DSL and Setup Up Stages
require 'capistrano/setup'
# Includes default deployment tasks
require 'capistrano/deploy'
require "capistrano/bundler" # NOTICE: capistrano/bundler, not capistrano/rails
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }