Skip to content

Instantly share code, notes, and snippets.

View pre's full-sized avatar
🚀
Cloud & Kubernetes

Petrus Repo pre

🚀
Cloud & Kubernetes
View GitHub Profile
@pre
pre / gist:4682211
Last active December 12, 2015 00:18
Convert a Quick Time screencast to GIF
# Convert a Quick Time screencast to GIF
# Creates two gifs, one HUGE and one optimized.
#
# Dependencies:
# % brew install ffmpeg imagemagick
#
# Props to http://schneems.com/post/41104255619/use-gifs-in-your-pull-request-for-good-not-evil
function gifify {
SRC="$1"
DEST="$2"
@pre
pre / gist:97e411ee31ecf3c09ab7
Created December 17, 2014 14:33
Push Notification test with PushPlugin
<script>
function onDeviceReady() {
pushNotification = window.plugins.pushNotification
tokenHandler = function(a) { console.log(a); steroids.logger.log(a); };
errorHandler = function(a) { console.log(a); steroids.logger.log(a); };
onNotificationAPN = function(a) { console.log(a); steroids.logger.log(a); };
@pre
pre / gist:b591aa341fd621e33eab
Created January 19, 2015 13:23
CordovaWebViewInterface
package org.apache.cordova;
import com.appgyver.ui.webview.AGWebViewInterface;
import android.view.View;
import android.view.ViewParent;
import android.webkit.WebChromeClient;
import java.util.HashMap;
@pre
pre / gist:94c55860f9f9d8def150
Created January 27, 2015 15:11
MapView rnd
- (void)viewDidLoad
{
[super viewDidLoad];
if(!self.mapView){
// create the map view
self.mapView = [[MKMapView alloc] initWithFrame:self.view.frame];
//configure the transparency of the webview
//and disable the interaction.. so all events are handled in the mapview
@pre
pre / gist:c29860151a904a1b2c4b
Created January 28, 2015 09:00
Crosswalk AndroidManifest.xml
?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.appgyver.runtime.standalone.chromium"
android:windowSoftInputMode="adjustPan">
<!-- Essentials -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
@pre
pre / gist:c1f17f5b585a9355acc8
Created January 28, 2015 09:15
MapViewController.m
//
// MapViewController.m
// AppGyver
//
// Created by Rafael on 6/03/14.
// Copyright (c) 2014 AppGyver Inc. All rights reserved.
//
#import "MapViewController.h"

This is an example of using Linux Kernel's Transparent Proxy to route all TCP traffic to docker containers without having to resort to PROXY protocol which is not supported by some applications (e.g. sshd). To get the demo to work you only need vagrant installed:

git clone [this-gist] tproxy-demo
cd tproxy-demo
vagrant up
@pre
pre / config
Created May 15, 2015 09:16
Reload config of a process
NAME="initial value"
@pre
pre / what-forces-layout.md
Created September 23, 2015 11:01 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@pre
pre / pg_interval_support_4_1.rb
Created February 2, 2017 14:59 — forked from Envek/pg_interval_support_4_1.rb
Enables PostgreSQL interval datatype support (as ActiveSupport::Duration) in Ruby on Rails 4.1 and 4.2
# Enables PostgreSQL interval datatype support (as ActiveSupport::Duration) in Ruby on Rails 4.1.
# Based on https://gist.github.com/clarkdave/6529610
require 'active_support/duration'
# add a native DB type of :interval
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES[:interval] = { name: 'interval' }
# add the interval type to the simplified_type list. because this method is a case statement
# we can't inject anything into it, so we create an alias around it so calls to it will call