This is a sample script for copying values from JSON to a struct using reflect package.
package main
import (
"encoding/json"
"fmt"
| package main | |
| import ( | |
| "fmt" | |
| "net/http" | |
| "strconv" | |
| "github.com/jinzhu/gorm" | |
| _ "github.com/jinzhu/gorm/dialects/sqlite" | |
| "github.com/labstack/echo" |
This is a sample script for copying values from JSON to a struct using reflect package.
package main
import (
"encoding/json"
"fmt"
| Ruby 2.1.0 in Production: known bugs and patches | |
| Last week, we upgraded the github.com rails app to ruby 2.1.0 in production. | |
| While testing the new build for rollout, we ran into a number of bugs. Most of | |
| these have been fixed on trunk already, but I've documented them below to help | |
| anyone else who might be testing ruby 2.1 in production. | |
| @naruse I think we should backport these patches to the ruby_2_1 branch and | |
| release 2.1.1 sooner rather than later, as some of the bugs are quite critical. | |
| I'm happy to offer any assistance I can to expedite this process. |
| $VERBOSE = nil | |
| require File.expand_path('../rooby', __FILE__) | |
| Person = Rooby::Class.new 'Person' do | |
| define :initialize do |name| | |
| @name = name | |
| end | |
| define :name do |
| /** | |
| * Scrolling shadows by @kizmarh and @leaverou | |
| * Only works in browsers supporting background-attachment: local; & CSS gradients | |
| * Degrades gracefully | |
| */ | |
| html { | |
| background: white; | |
| font: 120% sans-serif; | |
| } |
| body#-webkit-web-inspector #main{background-color:#002b36!important}body#-webkit-web-inspector #main .panel.network,body#-webkit-web-inspector #main .panel.timeline,body#-webkit-web-inspector #main .panel.profiles,body#-webkit-web-inspector #main .panel.audits,body#-webkit-web-inspector #main .panel.extension{background-color:#fff!important}body#-webkit-web-inspector #console-messages a:hover,body#-webkit-web-inspector #console-messages .console-formatted-function,body#-webkit-web-inspector #console-messages .console-formatted-object{color:#93a1a1!important}body#-webkit-web-inspector #console-prompt,body#-webkit-web-inspector #console-messages a,body#-webkit-web-inspector #console-messages .console-message,body#-webkit-web-inspector #console-messages .console-group-messages .section .header .title{color:#839496!important}body#-webkit-web-inspector #console-messages .console-formatted-null,body#-webkit-web-inspector #console-messages .console-formatted-undefined{color:#657b83!important}body#-webkit-web-inspect |
| // convert 0..255 R,G,B values to binary string | |
| RGBToBin = function(r,g,b){ | |
| var bin = r << 16 | g << 8 | b; | |
| return (function(h){ | |
| return new Array(25-h.length).join("0")+h | |
| })(bin.toString(2)) | |
| } | |
| // convert 0..255 R,G,B values to a hexidecimal color string | |
| RGBToHex = function(r,g,b){ |
| --colour | |
| -I app |
| def be_guest_member_of(expected) | |
| Class.new do | |
| def initialize(expected) | |
| @expected = expected | |
| end | |
| def matches?(target) | |
| @target = target | |
| @target.memberships.where(role: "guest").map(&:network).include? @expected | |
| end |
| module DonorsChoose | |
| extend self | |
| attr_accessor :api_key | |
| def projects_near_me(latitude, longitude) | |
| Request.get(:centerLat => latitude, :centerLong => longitude) | |
| end | |
| def projects_by_zip(zipcode) | |
| Request.get(:keyword => zipcode) |