Skip to content

Instantly share code, notes, and snippets.

View franckverrot's full-sized avatar
📚
🥋

Franck Verrot franckverrot

📚
🥋
View GitHub Profile
#!/usr/bin/env bash

# Assuming OS X Yosemite 10.10.4

# Install XCode and command line tools
# See https://itunes.apple.com/us/app/xcode/id497799835?mt=12#
# See https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/xcode-select.1.html
xcode-select --install
@franckverrot
franckverrot / log.sql
Created July 11, 2015 17:35
Subplans :-((((
# explain analyze select *, (select count(1) from generate_series(1,1000000) where users.id = generate_series) from users limit 1;
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.00..12.57 rows=1 width=7138) (actual time=198.759..198.760 rows=1 loops=1)
-> Seq Scan on users (cost=0.00..314.37 rows=25 width=7138) (actual time=198.758..198.758 rows=1 loops=1)
SubPlan 1
-> Aggregate (cost=12.51..12.52 rows=1 width=0) (actual time=198.743..198.743 rows=1 loops=1)
-> Function Scan on generate_series (cost=0.00..12.50 rows=5 width=0) (actual time=101.312..198.737 rows=1 loops=1)
Filter: (users.id = generate_series)
Rows Removed by Filter: 999999
@franckverrot
franckverrot / test.sql
Created July 9, 2015 11:54
PostgreSQL OVERLAPS function and infinity timestamps
-- ]-inf;today[ overlaps [today,+inf[
# select ('-infinity'::timestamp, now()) overlaps (now(), 'infinity'::timestamp) ;
overlaps
----------
f
(1 row)
-- ]-inf;tomorrow[ overlaps [today,+inf[
# select ('-infinity'::timestamp, now() + interval '1 day') overlaps (now(), 'infinity'::timestamp) ;
overlaps
require 'formula'
class Kindlegen < Formula
url 'http://s3.amazonaws.com/kindlegen/KindleGen_Mac_i386_v2_7.zip'
homepage 'http://www.amazon.com/gp/feature.html?docId=1000234621'
sha256 'e75aaf4a70875eedbcd69c6f44c22bbadf5a48a81de5130947df4698c34c6597'
version '2.7'
skip_clean 'bin'
@franckverrot
franckverrot / test.log
Created June 30, 2015 16:39
USING statement in PG's ALTER COLUMN
# Create a table
[email protected]/19678=# create table ary(foo text); insert into ary values ('hello world'),('foo bar baz'); select * from ary;
CREATE TABLE
INSERT 0 2
foo
-------------
hello world
foo bar baz
(2 rows)
@franckverrot
franckverrot / test.sql
Created June 28, 2015 08:25
Verbose constraint violation message
λ /usr/local/pgsql/bin/psql
psql (9.5devel)
Type "help" for help.
[email protected]/49942=# create table foo(bar varchar(4), baz varchar(2));
CREATE TABLE
[email protected]/49942=# insert into foo values ('foo!', 'ok');
INSERT 0 1
@franckverrot
franckverrot / test.rb
Created March 12, 2015 22:12
||= vs = .. ||
>> $-w=true
=> true
>> @a ||= @b
(irb):2: warning: instance variable @b not initialized
=> nil
>> @c = @c || @d
(irb):3: warning: instance variable @c not initialized
(irb):3: warning: instance variable @d not initialized
=> nil
@franckverrot
franckverrot / test.rb
Created March 12, 2015 21:40
||= and &&= don't complain the same way
irb(main):001:0> $-w = true
=> true
irb(main):002:0> @foo ||= true
=> true
irb(main):003:0> @bar &&= true
(irb):3: warning: instance variable @bar not initialized
=> nil
require 'benchmark/ips'
class Foo
def bar
# "Foo#bar"
end
end
module Bar
def bar

The easiest way to start using the LLVM C++ API by example is to have LLVM generate the API usage for a given code sample. In this example it will emit the code required to rebuild the test.c sample by using LLVM:

$ clang -c -emit-llvm test.c -o test.ll
$ llc -march=cpp test.ll -o test.cpp