Skip to content

Instantly share code, notes, and snippets.

@daemonsy
daemonsy / gist:2923110
Created June 13, 2012 09:43
Problem Faced with RestKit when doing Inverse Mapping for serialization
// .h
@interface MQCheckoutObject : NSObject
@property NSString *creditCardNumber;
@property NSString *cvvNumber;
@property NSString *creditCardExpiryDate;
@property NSString *customerName;
@property NSString *customerEmail;
@daemonsy
daemonsy / london.markdown
Last active December 24, 2015 21:39
Some protips for guys moving to London to join AlphaSights

Housing

Renting a room in London can cost around £500 - £900, higher in Zone 1 & 2. An apartment can cost anywhere between £1,100 to £2,500, usually you get much more value for money away from Central London. Other than rent, look out for the bills, including Internet, water, gas and Council Tax. Most quotes exclude Council Tax. It will be usually cheaper if you rent a full shared apartment instead of trying to find ensuite or studio apartments.

Generally, it would be great to have tube connections to Bond Street Station or Oxford Circus. If you plan to cycle to work, do consider the route / distance to the office. If you're new to the city, staying near friends can be a great benefit too.

Some Area Guides:

Time Out

@daemonsy
daemonsy / gist:7476823
Last active December 28, 2015 09:09
A little presentation on External Authentication
Authentication vs Authorisation
## What we really want:
Us: "Hey trusted partner, who is this guy?"
Provider: "He is Damon..."
We do whatever we want from this point onwards.
@daemonsy
daemonsy / get.js
Last active April 4, 2016 18:18
blog post: Get Example
var headers = function() {
return ({
“Authorization”: `Bearer ${auth.accessToken()}`,
});
};
get(path, query = {}) {
return new Promise((resolve, reject) => {
  request
.get(apiPath(path))
@daemonsy
daemonsy / fetch.js
Created April 4, 2016 19:15
Blog Post: Pseudo code for fetch
return fetch(this._uri, {
...this._init,
body: JSON.stringify({
query: request.getQueryString(),
variables: request.getVariables(),
}),
headers: {
...this._init.headers,
'Accept': '*/*',
'Content-Type': 'text/plain',
@daemonsy
daemonsy / produce-form-data.js
Created April 4, 2016 19:16
Blog Post: formData hack
defaultNetworkLayer._sendQuery = function(request) {
var formData = new FormData();
formData.append("query", request.getQueryString()); // Always a string anyway
formData.append("variables", JSON.stringify(request.getVariables())); // A JS object, JSON it.
return fetch(this._uri, {
...this._init,
body: formData,
headers: {
...this._init.headers,
@daemonsy
daemonsy / graph_execute.rb
Created April 4, 2016 19:18
Blog Post: GraphQL Execution
def show
variables = params[:variables] # old code when using JSON
variables = JSON.parse(params[:variables]) # new code after changing fetch to formData
execution = Dragon::Schema.execute(params[:query],
variables: variables,
context: {
user: current_user
}
)
render json: execution
@daemonsy
daemonsy / cameratag.js
Created April 6, 2016 21:05
Putting it here to discuss to understand bloody Cameratag's load cycle
ct_browser = function(){
var ua= navigator.userAgent, tem,
M= ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
if(/trident/i.test(M[1])){
tem= /\brv[ :]+(\d+)/g.exec(ua) || [];
return 'IE '+(tem[1] || '');
}
if(M[1]=== 'Chrome'){
tem= ua.match(/\b(OPR|Edge)\/(\d+)/);
if(tem!= null) return tem.slice(1).join(' ').replace('OPR', 'Opera');
ct_browser = function(){
var ua= navigator.userAgent, tem,
M= ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
if(/trident/i.test(M[1])){
tem= /\brv[ :]+(\d+)/g.exec(ua) || [];
return 'IE '+(tem[1] || '');
}
if(M[1]=== 'Chrome'){
tem= ua.match(/\b(OPR|Edge)\/(\d+)/);
if(tem!= null) return tem.slice(1).join(' ').replace('OPR', 'Opera');
@daemonsy
daemonsy / static.json
Last active May 3, 2016 04:12
Dragon's static.json with information redacted
{
"root": "dist/",
"https_only": true,
"routes": {
"/**": "index.html"
},
"proxies": {
"/api/": {
"origin": "https://backend.example.com/api"
}