Skip to content

Instantly share code, notes, and snippets.

View MacKentoch's full-sized avatar
👨‍💻

Erwan DATIN MacKentoch

👨‍💻
  • France
View GitHub Profile
var hello= 'bonjour';
var will = {
hello : 'hello',
tab : [1,2],
say : function(){
console.info(this.hello)
},
iterateSay : function(){
this.tab.every(function(value, index){
var objet1 = {
prop1 : 'objet1.prop1',
prop2 : 'something Else'
};
//some kind forEach over object properties in ES5
Object.keys(objet1).forEach((key)=> {
console.info(objet1[key]);
});
function authInterceptor($httpProvider) {
$httpProvider.interceptors.push(($timeout, $q, $injector, userStorage) => {
let $http, $state, $mdDialog, $mdToast, $signin;
// this trick must be done so that we don't receive
// `Uncaught Error: [$injector:cdep] Circular dependency found`
<!DOCTYPE html>
<html ng-app="demoApp">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Erwan DATIN">
<!-- angularjs -->
function get(url) {
// Return a new promise.
return new Promise(function(resolve, reject) {
// Do the usual XHR stuff
var req = new XMLHttpRequest();
req.open('GET', url);
req.onload = function() {
// This is called even on 404 etc
// so check the status
{
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
{
"ecmaFeatures": {
"modules": true
},
"rules": {
"quotes": [ 2, "single" ],
"semi": [ 2, "always" ],
},
"env": {
"es6": true,
@MacKentoch
MacKentoch / gist:32c6000a34c318be814c
Created February 4, 2016 20:44 — forked from marty-wang/gist:5a71e9d0a6a2c6d6263c
Compile and deploy React Native Android app of Release version to device.
Disclaimer: The instructions are the collective efforts from a few places online.
Nothing here is my original. But I want to put them together in one place to save people from spending the same time as I did.
First off, bundle.
==================
1. cd to the project directory
2. Start the react-native packager if not started
3. Download the bundle to the asset folder:
curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
@MacKentoch
MacKentoch / IE fix for location-origin.js
Created February 22, 2016 10:18
A fix for window.location.origin in Internet Explorer
if (!window.location.origin) {
window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: '');
}
declare let componentHandler: any; // need to use external in angular2? Ok no pb, but declare it before like that
@Component({
selector: 'app',
...
})
export class App implements AfterViewInit {
ngAfterViewInit() {
componentHandler.upgradeDom(); // upgrade all mdl components