Skip to content

Instantly share code, notes, and snippets.

View typeoneerror's full-sized avatar
🤠
iOS, Capacitor, Ember, Vue, Rails

Benjamin Borowski typeoneerror

🤠
iOS, Capacitor, Ember, Vue, Rails
View GitHub Profile
@typeoneerror
typeoneerror / psql.sql
Created January 6, 2012 21:33
grouping, counting
select
date(created_at) as the_date,
extract(day from created_at) as the_day,
count(id) as count_all
from results
group by the_date, the_day
order by the_date;
@typeoneerror
typeoneerror / pages-watermark.md
Created December 28, 2011 19:35
How to create a global watermark in Apple Pages.
  • Go to Format > Advanced and check "Make Master Objects Selectable".
  • Drop the image you want to use as your watermark into the document.
  • With the image selected, under "Wrap" options in the "Inspector" select "In Background" as "Object Placement".
  • Check that "Background objects are selectable".
  • Go back to Format > Advanced and check "Move Object to Section Master".
  • Uncheck "Background objects are selectable"

Your image is now the background image for all pages and is essentially a watermark.

NSMutableAttributedString *attrStr = [NSMutableAttributedString attributedStringWithString:content];
range = NSMakeRange(0, [attrStr length]);
[attrStr setFont:[UIFont fontWithName:LBFontBryantMedium size:16]];
[attrStr setTextAlignment:CTTextAlignmentFromUITextAlignment(UITextAlignmentLeft)
lineBreakMode:CTLineBreakModeFromUILineBreakMode(UILineBreakModeWordWrap)];
[attrStr addAttribute:(NSString *)kCTKernAttributeName
value:[NSNumber numberWithFloat:-0.4]
range:range];
[attrStr addAttribute:(NSString *)kCTParagraphStyleAttributeName
NSMutableAttributedString *attrStr = [NSMutableAttributedString attributedStringWithString:@"Text to kern"];
[attrStr addAttribute:(NSString *)kCTKernAttributeName
value:[NSNumber numberWithInt:-1]
range:NSMakeRange(0, [attrStr length])];
[self.introLabel setAttributedText:attrStr];
// test for fixed positioning
Modernizr.addTest("positionfixed", function()
{
// OK since iOS 5
//if (navigator.userAgent.match(/AppleWebKit\/(.*)Mobile\//)) return false;
if (navigator.userAgent.match(/Android(.*)Mobile/)) return false;
var test = document.createElement("div"),
control = test.cloneNode(false),
fake = false,
#my
select code,id from reactions group by code;
#pg
select distinct on (code) code,id from reactions;
@typeoneerror
typeoneerror / count.sql
Created December 2, 2011 02:06
count of results per day of last week
SELECT
EXTRACT(DAY FROM created_at) AS the_day,
COUNT(created_at) AS count_all
FROM "results"
WHERE "results"."result_type" = 'outcome'
AND (DATE("results"."created_at") BETWEEN '2011-11-21' AND '2011-12-01')
GROUP BY created_at
ORDER BY created_at
class Result < ActiveRecord::Base
class << self
def past_week_span(date = nil)
date ||= Date.today
(date.beginning_of_week...date.beginning_of_week + 7).collect do |date|
date.day
end
end
end
end
module AdminHelper
def link_to_direction(field, title = nil)
title ||= field.humanize
dir = @order_dir.downcase == 'asc' ? 'desc' : 'asc'
link_to title, yield(:order => field, :dir => dir) if block_given?
end
end
= link_to_direction('name') {|params| admin_artists_path(params)}
require 'yaml'
asset_path = File.expand_path(File.dirname(__FILE__) + '/../lib/assets/content/')
assets = Dir.glob(asset_path + '/*.yml')
assets.each do |url|
key = File.basename(url, '.yml')
parsed = YAML.load_file(url)
if parsed
klass = Admin.const_get(key.classify)