Skip to content

Instantly share code, notes, and snippets.

Avatar
💀
alter.

gregory nicholas gregorynicholas

💀
alter.
View GitHub Profile
View coderstv-router.js
Router.map(function () {
this.route('index', {
controller: 'BasicController',
layoutTemplate: 'indexLayout',
path: '/',
waitOn: function () {
return Meteor.subscribe('Channels');
}
});
View meteor_ytapi.js
Meteor.startup(function () {
Session.set('YTApiReady', false);
Session.set('channelRendered', false);
});
onYouTubeIframeAPIReady = function() {
Session.set('YTApiReady', true);
};
Template.channel.created = function () {
View mesosphere.js
Mesosphere.registerRule('checkDate', function (fieldValue, ruleValue) {
console.log('checkDate')
if (!ruleValue) {
return true;
}
var date = fieldValue.split('-'),
today = new Date((new Date()).setHours(0, 0, 0, 0));
date = new Date(date[0], date[1] - 1, date[2]);
@gregorynicholas
gregorynicholas / show-user-selection.js
Created Feb 20, 2014
hack attempt at a script to only display text in a user selection range
View show-user-selection.js
a.ondrag = function(e){
var text = "";
if (typeof window.getSelection != "undefined") {
var sel = window.getSelection();
if (sel.anchorNode && sel.anchorNode.id && sel.anchorNode.id !== 'message') {
console.info('--- sel.anchorNode.id:', sel.anchorNode.id);
// return true;
}
View python_startup.py
def _init():
import atexit
import os
import sys
import readline
import types
import time
import uuid
import pprint
import hashlib
View README.md

Create a Meteor app and put the client_/server_ files in a client/server directories. Also, create a public dir to save the uploaded files.

View AssetsClient.coffee
Template.assetUpload.events(
'drop #asset-upload-dropzone': (e) ->
e.stop()
$(e.target).removeClass 'dropzone-hover'
new AssetUpload(e)
'dragenter #asset-upload-dropzone': (e) ->
e.stop()
$(e.target).addClass 'dropzone-hover'
View gist:68e345aa2a56859b8cf4
## RubyMotion
imageData = UIImage.UIImageJPEGRepresentation(@image_view.image, 1)
encodedData = [imageData].pack("m0")
data["image"] = encodedData
BW::HTTP.post("http://localhost:3000/upload}", {payload: data}) do |response|
if response.ok?
end
end
View colors
#!/bin/bash
echo -e "\033[0mCOLOR_NC (No color)"
echo -e "\033[1;37mCOLOR_WHITE\t\033[0;30mCOLOR_BLACK"
echo -e "\033[0;34mCOLOR_BLUE\t\033[1;34mCOLOR_LIGHT_BLUE"
echo -e "\033[0;32mCOLOR_GREEN\t\033[1;32mCOLOR_LIGHT_GREEN"
echo -e "\033[0;36mCOLOR_CYAN\t\033[1;36mCOLOR_LIGHT_CYAN"
echo -e "\033[0;31mCOLOR_RED\t\033[1;31mCOLOR_LIGHT_RED"
echo -e "\033[0;35mCOLOR_PURPLE\t\033[1;35mCOLOR_LIGHT_PURPLE"
echo -e "\033[0;33mCOLOR_YELLOW\t\033[1;33mCOLOR_LIGHT_YELLOW"
View gist:08a9c5624984ec7e0049
#!/usr/bin/env ruby
# To use, put this in your bashrc:
# complete -C path/to/script -o default your_command_or_commands_here
# example, to complete the foo and bar commands with the foo.rb script: complete -C ~/bin/foo.rb -o default foo bar
prefix = ARGV[1]
words = `some command here, or just any array`.split.uniq
words = words.select {|w| /^#{Regexp.escape prefix}/ =~ w} if prefix
You can’t perform that action at this time.