Skip to content

Instantly share code, notes, and snippets.

View morenoh149's full-sized avatar
💭
Working from 🛰

Harry Moreno morenoh149

💭
Working from 🛰
View GitHub Profile
@mlynch
mlynch / directive.js
Created April 18, 2014 21:02
Starter directive
angular.module('myApp.directives', [])
.directive('myCanvas', function() {
return {
// Angular needs to know what type of usage we want to allow for this (attribute, class name, or tag).
// For this example, a tag is great.
restrict: 'E',
// We want to replace the original custom tag with a template
replace: true,
@Kuirak
Kuirak / client
Last active August 29, 2015 14:00
$sailsSocket.subscribe('event',function(message){
if(message.verb ==='created'){
$scope.events.push(message.data);
}
});
$sailsSocket.get('/api/event/subscribe').success(function(data){
console.log("Subscribed")
});
$sailsSocket.get('/api/event').success(function(data){
$scope.events =data;
<%
# Build the helper file
# assumes config.assets.paths << Rails.root.join('tmp', 'teaspoon', 'assets') in development.rb
tmp_assets = Rails.root.join("tmp/teaspoon/assets")
spec_helper = File.join(tmp_assets, "spec_helper.js")
FileUtils.mkdir_p(File.dirname(spec_helper)) unless File.directory?(File.dirname(spec_helper))
specs = @suite.spec_assets(false).map{ |s| "#{s.gsub(/\.js.*$/, "")}" }
#app/inputs/collection_check_boxes_input.rb
class CollectionCheckBoxesInput < SimpleForm::Inputs::CollectionCheckBoxesInput
def item_wrapper_class
"checkbox-inline"
end
end
@th3hunt
th3hunt / teaspoon.rb
Last active August 18, 2016 00:41
A teaspoon boot loader that works with browserify rails
# config/initializers/teaspoon.rb
module Teaspoon
module BootHelper
def create_browserify_bundle(suite)
bundle = File.join(Rails.root, 'tmp/javascripts', "suites/#{suite.name}.js")
bundle_dir = File.dirname(bundle)
FileUtils.mkdir_p(bundle_dir) unless File.directory?(bundle_dir)
specs = suite.spec_assets(false).map { |asset| "#{asset.gsub(/\.js.*$/, '')}" }
@David-Guillot
David-Guillot / schemacrawler.sh
Created March 2, 2017 08:42
Make the SchemaCrawler shell script work from any working directory
DIR=$(dirname $(readlink -f "$0"))
java -cp $(echo $DIR/lib/*.jar | tr ' ' ':'):config schemacrawler.Main "$@"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int is_valid(const char* password) {
if (strcmp(password, "poop") == 0) {
return 1;
} else {
return 0;
}
@brigand
brigand / high-impact-redux-tests.md
Last active April 12, 2017 21:01
A guide to writing high impact redux tests.

Some people will tell you to test everything in your app. If you have time to kill, go for it. For most of us, we want to focus on tests that help us sleep at night. We'll be using jest in this guide, mostly because it provides snapshot testing.

mapDispatchToProps

This isn't something people normally test, but it saves us from typos that only show up in response to user interaction. Often we fail to dispatch all of the actions in our manual testing of UIs.

The premise here is simple, we want to know that all of our keys are actual functions. We'll be

@morenoh149
morenoh149 / s3_constants.py
Last active April 25, 2017 21:15
Demonstrate how to fill and empty an existing s3 bucket.
S3_ACCESS_KEY = 'foo'
S3_SECRET_KEY = 'foo'
S3_BUCKET = 'foo'
d = dict()
d['title_list'] = []
now = datetime.datetime.now()
base_title_qs = Title.objects.distinct().filter(state='P').order_by('stage', 'category')
if section == 'c':
base_title_qs = base_title_qs.filter(stage__id=2)