Skip to content

Instantly share code, notes, and snippets.

In Rails layout file:
<script>
function authToken(){
return '<%= form_authenticity_token if protect_against_forgery? -%>';
}
</script>
In FileUploader init code:
uploader = new qq.FileUploader({
...
{
"display_date": "2003",
"medium": "Site specific composition",
"title": "Emersion",
"thumbnail_mimetype": "image/jpeg",
"thumbnail": "crypth.jpg",
"calendar_date": "1980-01-01 00:00:00",
"thumbnail_path": "30353_crypth.jpg",
"images": [
{
REQUEST:
{:method=>"moo.pack.createTrialPartnerPack", :product=>"businesscard", :pack=>"{\"numCards\":50,\"productCode\":\"businesscard\",\"productVersion\":1,\"imageBasket\":{\"immutable\":false,\"items\":[{\"shouldEnhance\":false,\"copyrightOwner\":null,\"cacheId\":\"partner_interface_uploader:b9df2359-1018-558545d5-4e4a7003-aa04.pdf\",\"type\":\"front\",\"resourceUri\":\"filestore://image_original/b9df2359-1018-558545d5-4e4a7003-aa04.pdf\",\"removable\":true,\"croppable\":true,\"imageBox\":null,\"imageItems\":[{\"type\":\"print\",\"resourceUri\":\"https://secure.moo.com/is/o/b9df2359-1018-558545d5-4e4a7003-aa04.pdf\",\"width\":1500,\"height\":1007,\"rotation\":0},{\"type\":\"preview\",\"resourceUri\":\"https://secure.moo.com/is/r/1024/b9df2359-1018-558545d5-4e4a7003-aa04.png\",\"width\":1024,\"height\":687,\"rotation\":0},{\"type\":\"thumbnail\",\"resourceUri\":\"https://secure.moo.com/is/t/75/b9df2359-1018-558545d5-4e4a7003-aa04.png\",\"width\":75,\"height\":75,\"rotation\":0}]},{\"shouldEnhance\":false,\
sign_ups_referred_to_date = FlupTrackingEvent.find(:event_type => "sign_up", :inviter => {:$ne => ""}, :created_at => {:$lte => new_time}).to_a
invites_to_date = FlupTrackingEvent.find(:event_type => "external_invite", :created_at => {:$lte => new_time}).to_a
@days << {
:day => this_time,
:invites => FlupTrackingEvent.find(:event_type => "external_invite", :created_at => {:$gte => this_time, :$lte => new_time}).to_a,
:sign_ups_total => FlupTrackingEvent.find(:event_type => "sign_up", :created_at => {:$gte => this_time, :$lte => new_time}).to_a,
:sign_ups_reffered => FlupTrackingEvent.find(:event_type => "sign_up", :inviter => {:$ne => ""}, :created_at => {:$gte => this_time, :$lte => new_time}).to_a,
:sign_ups_reffered_to_date => sign_ups_referred_to_date,
:items => FlupTrackingEvent.find(:created_at => {:$gte => this_time, :$lte => new_time}).to_a,
+--------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| count(question_id) | question |
+--------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 3313 | In the <b>last 3 months</b>, approximately how often have you ridden a bike since the Challenge? |
| 3292 | Thinking about the <b>last 3 months</b>, did you ride your bike...? |
| 2392 | In the last <b>3 months</b>, approximately how ofte
@lukesaunders
lukesaunders / edit.html.erb
Created January 30, 2012 00:06
Create multiple models at once using fields_for
<h1>Editing event</h1>
<%= twitter_bootstrap_form_for(@event) do |f| %>
<%= f.inputs "General" do %>
<%= render :partial => 'form', :locals => { :f => f } %>
<% end %>
<%= f.inputs "Jobs" do %>
<%= f.fields_for(:jobs, @new_jobs) do |jf| %>
<%= jf.hidden_field :name %>
@lukesaunders
lukesaunders / event_job_collection.rb
Created January 30, 2012 01:39
Model for creating multiple model instances at once
class EventJobCollection
include ActiveModel::AttributeMethods
extend ActiveModel::Naming
include ActiveModel::Conversion
attr_accessor :event, :jobs
delegate :id, :to => :event, :prefix => :event
def initialize(event, event_params = nil)
type Query {
pool(poolId: String!): Pool
pools(orderBy: PoolOrderAttribute, limit: Int): [Pool]
poolHistory(from: Int, until: Int, interval: Interval): PoolHistory
}
# A type representing the current state of a pool. To get historical data or averages use XXX
type Pool {
# the asset name in the format "CHAIN.TICKER-SYMBOL" e.g. "BNB.BTCB-101"
asset: String!
specVersion: 0.0.2
schema:
file: ./schema.graphql
dataSources:
- kind: ethereum/contract
name: Contract
network: mainnet
source:
address: "0x84edffa16bb0b9ab1163abb0a13ff0744c11272f"
abi: Contract
import knex from '../../../lib/database.js';
import sleep from '../../../lib/utils/sleep';
import { compareAsc, format, addDays, subDays, addYears, subMonths, subYears, parse } from 'date-fns';
import Web3 from 'web3';
import contractABI from './pooledStakingAbi.js';
const createCsvWriter = require('csv-writer').createObjectCsvWriter;
process.on('unhandledRejection', up => { throw up });
const web3 = new Web3('http://localhost:9545');