Skip to content

Instantly share code, notes, and snippets.

View AlexandreRoba's full-sized avatar

Alexandre Roba AlexandreRoba

View GitHub Profile
@AlexandreRoba
AlexandreRoba / 0_reuse_code.js
Created April 22, 2014 11:04
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@AlexandreRoba
AlexandreRoba / Global.asax.cs
Last active August 29, 2015 14:19 — forked from sitefinitysteve/Global.asax.cs
Using SiteFinity and Service Stack. The route is defined by the location path="RestApi" and the route defined on the service. In this case /RestApi/Hello
using System;
using System.Linq;
using Telerik.Sitefinity.Services;
namespace SitefinityWebApp
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
@AlexandreRoba
AlexandreRoba / gist:f88ba4af1519f82cc7e2
Created June 22, 2015 21:46
Creating a View that inherits crom UIView in typescript
import placeHolder = require("ui/placeholder");
import imageSource = require("image-source");
class PSDemoView extends UIView{
drawRect(rect:CGRect){
var context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context,UIColor.redColor().CGColor);
CGContextFillRect(context,CGRectMake(40,40,100,200));
}
}
@AlexandreRoba
AlexandreRoba / server.py
Created January 20, 2016 19:17 — forked from fmoo/server.py
CONNECT-enabled HTTP Proxy Server
from twisted.web.proxy import Proxy, ProxyRequest
from twisted.internet.protocol import Protocol, ClientFactory
import urlparse
from twisted.python import log
class ConnectProxyRequest(ProxyRequest):
"""HTTP ProxyRequest handler (factory) that supports CONNECT"""
connectedProtocol = None
@AlexandreRoba
AlexandreRoba / better-nodejs-require-paths.md
Created February 10, 2016 22:49 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@AlexandreRoba
AlexandreRoba / bootstrap.js
Created February 24, 2016 19:54 — forked from chrisjhoughton/bootstrap.js
SailsJS Geo-encoding and lookup
module.exports.bootstrap = function (cb) {
// Ensure we have 2dsphere index on Property so GeoSpatial queries can work!
sails.models.YOURMODEL.native(function (err, collection) {
collection.ensureIndex({ coordinates: '2dsphere' }, function () {
// It's very important to trigger this callack method when you are finished
// with the bootstrap! (otherwise your server will never lift, since it's waiting on the bootstrap)
cb();
@AlexandreRoba
AlexandreRoba / gist:4885392198d949921e7ecd0b0f2c8e9e
Created September 7, 2016 13:07
SetVideoBackground Xamarin IOS
private void SetVideoBackground()
{
var asset = AVAsset.FromUrl(Foundation.NSUrl.FromFilename("BackgroundVideo.mp4"));
var playerItem = new AVPlayerItem(asset);
var player = new AVPlayer(playerItem);
var playerLayer = AVPlayerLayer.FromPlayer(player);
playerLayer.Frame = this.View.Frame;
playerLayer.VideoGravity = AVLayerVideoGravity.ResizeAspectFill;
playerLayer.ZPosition = -1;
this.View.Layer.AddSublayer(playerLayer);
@AlexandreRoba
AlexandreRoba / gist:c47cff7e17bcf7b8a8206e536628dc71
Created September 15, 2016 12:23
Using the Google Place Autocomplete View Controller
void BtnNext_TouchUpInside(object sender, EventArgs e)
{
var FakeCoordinates = new CLLocationCoordinate2D()
{
Latitude = 54.135364,
Longitude = -0.797888
};
var north = LocationWithBearing(45, 3000, FakeCoordinates);
var east = LocationWithBearing(225, 3000, FakeCoordinates);

Keybase proof

I hereby claim:

  • I am alexandreroba on github.
  • I am alexandreroba (https://keybase.io/alexandreroba) on keybase.
  • I have a public key whose fingerprint is AAB6 3F61 E5D9 105E AEFA C419 8440 67ED 5C2B C060

To claim this, I am signing this object:

# Set variables in .bash_profile file
# don't forget to change your path correctly!
export GOPATH=$HOME/golang
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin