Skip to content

Instantly share code, notes, and snippets.

@nateroling
nateroling / gist:6042612
Created July 19, 2013 21:53
After some struggling, this is the pattern I came up with for mapping JSON data to nested custom classes.
function Parent(data) {
// Let constructor work or without new.
// http://ejohn.org/blog/simple-class-instantiation/
// This makes it easier to use _.map below.
if (!(this instanceof Parent)) {
return new Parent(data);
}
// Use JSON data passed in, or set defaults values.
require 'net/http'
names=%w{ ututtza publicstaticmainvoid netscrape getus }
on_off = {0=>"OFFline", 1=>"ONline"} #hash for when printing out if online
names.each do |name|
uri = URI("http://census.soe.com/xml/get/ps2-beta/character/?name.first_lower=#{name}&c:show=name,online_status%20&c:resolve=online_status") #using planetside 2 API to get character information just need online_status value
status= Net::HTTP.get(uri)
first_junk=status.split #initial split of string to get online or offline
onlinestatus=first_junk.at(9).split('"') #second split which returns 0 when offline and 10 when online in the (1) index of the array
require 'net/http'
require 'json'
names=%w{ ututtza publicstaticmainvoid netscrape getus }
# Use a different method of string interpolation/templating.
# This way I can define the URL template once here, and then insert different
# names into it later.
# See: http://www.ruby-doc.org/core-1.9.3/String.html#method-i-25
uri_template = "http://census.soe.com/json/get/ps2-beta/character/?name.first_lower=%{name}&c:show=name,online_status%%20&c:resolve=online_status"
@nateroling
nateroling / gist:6161980
Last active December 20, 2015 16:29
Doing some decidedly advanced and ruby-specific things here, don't worry if they don't make sense yet. Let me know what you have questions on.
require 'net/http'
require 'json'
# Q:
# I kind of understand how this works. Each class is like a user made method
# (or function as I would call it). So whenever you call the player class it
# will run the parameters through. I read something about you can use that to
# make it more manageable. And you can mage gems out of it (or something - not
# quite sure on that part).
@nateroling
nateroling / deploy.addendum.rb
Last active July 15, 2016 07:11
Roots Bedrock: Copy production assets for Roots theme
# The Roots theme by default does not check production assets into Git, so
# they are not deployed by Capistrano when using the Bedrock stack. The
# following will compile and deploy those assets. Copy this to the bottom of
# your config/deploy.rb file.
# Based on information from this thread:
# http://discourse.roots.io/t/capistrano-run-grunt-locally-and-upload-files/2062/7
# and specifically this gist from christhesoul:
# https://gist.github.com/christhesoul/3c38053971a7b786eff2
@nateroling
nateroling / gist:8a1829a7f885cfa8bd7b
Created December 15, 2014 20:50
Bootstrap Grid Child Columns
//
// Bootstrap Grid Child Columns
// See: http://nateroling.com/2014/11/25/aligning-nested-grids/
// --------------------------------------------------
.make-xs-child-column(@columns; @parent-columns; @gutter: @grid-gutter-width) {
.make-sm-column(@columns, @gutter);
width: percentage((@columns / @parent-columns));
}
.make-xs-child-column-offset(@columns; @parent-columns) {
// http://stackoverflow.com/questions/6654958/make-body-have-100-of-the-browser-height
html { height: 100%; }
body { min-height: 100%; }
// http://www.paulirish.com/2012/box-sizing-border-box-ftw/
html { box-sizing: border-box; }
*, *:before, *:after { box-sizing: inherit; }
// http://alistapart.com/article/axiomatic-css-and-lobotomized-owls
* { margin: 0; padding: 0; }
Blogs
http://www.smashingmagazine.com
http://alistapart.com
http://uxmovement.com
https://uxmag.com
http://www.lukew.com/ff/
https://css-tricks.com
Schools
#!/bin/bash
#
# Example:
# > just publish
# Finds and executes scripts/publish or script/publish
# TODO Find and execute grunt/gulp tasks
CMD=''
if [ -x ./scripts/$1 ]; then
timestamp = 1479761724
timestamplong = 1479761724389
millisecond = 389
dayseconds = 53724
time = 2:55pm