Skip to content

Instantly share code, notes, and snippets.

View MacKentoch's full-sized avatar
👨‍💻

Erwan DATIN MacKentoch

👨‍💻
  • France
View GitHub Profile
import React, { Component, PropTypes } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
ScrollView,
Animated
} from 'react-native';
export function formatBytes(bytes, decimals) {
if (bytes === 0) {
return '0 Byte';
}
const k = 1000; // or 1024 for binary
const dm = decimals + 1 || 3;
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
# fetch
git remote add <username> <URL>
git fetch <username>
git checkout -b <pull-request-branch> <username>/<pull-request-branch>
#merge not fast-forward
git checkout master
git merge <pull-request-branch>
window.addEventListener('DOMContentLoaded', function() {
console.log('window - DOMContentLoaded - capture'); // 1st
}, true);
document.addEventListener('DOMContentLoaded', function() {
console.log('document - DOMContentLoaded - capture'); // 2nd
}, true);
document.addEventListener('DOMContentLoaded', function() {
console.log('document - DOMContentLoaded - bubble'); // 2nd
});
window.addEventListener('DOMContentLoaded', function() {
@MacKentoch
MacKentoch / GSEventEmitter.h
Created February 20, 2017 19:10 — forked from andybangs/GSEventEmitter.h
Example RCTEventEmitter Subclass
#import "RCTEventEmitter.h"
#import "RCTBridge.h"
@interface GSEventEmitter : RCTEventEmitter <RCTBridgeModule>
+ (BOOL)application:(UIApplication *)application didSightBeacon:(NSString *)beaconID;
+ (BOOL)application:(UIApplication *)application didDepartBeacon:(NSString *)beaconID;
@end
@MacKentoch
MacKentoch / GSEventEmitter.h
Created February 20, 2017 19:10 — forked from andybangs/GSEventEmitter.h
Example RCTEventEmitter Subclass
#import "RCTEventEmitter.h"
#import "RCTBridge.h"
@interface GSEventEmitter : RCTEventEmitter <RCTBridgeModule>
+ (BOOL)application:(UIApplication *)application didSightBeacon:(NSString *)beaconID;
+ (BOOL)application:(UIApplication *)application didDepartBeacon:(NSString *)beaconID;
@end

NEXUS 5X: Fix lineage 14.1 OS vendor mismatch error (N2G47F)

Issue is due to the fact that lineage 14.1 bullhead nightlies are based on the 7.1.2 N2G47F (Apr 2017) monthly update from google.

More explanations in xda-developers.

PREREQUISITE

This assumes:

  • you already know a bit about flashing you android device and you already installed TWRP.

adb and fastboot must know

Install android SDK (bottom of the page) or full android studio if you need to develop on android.

fastboot looks like adb but it is used when device is in bootloader (or fastboot).

Check connected devices

adb:

@MacKentoch
MacKentoch / admin-template.html
Created July 9, 2017 07:35
basic html 5 admin template with collapsible side menu
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Admin basic template</title>
<style>
body {
margin: 0 !important; /*suppress all default margins*/

How to localize an app’s name with InfoPlist.strings

  • In Xcode go to File, New, File..
  • Select iOS (or the platform you are working with), Resource, Strings File, Next.
  • Name the file InfoPlist.strings (case sensitive).
  • If you only plan on having one App name for your project then I recommend placing the file in the same directory as your Localizable.strings file. However, if you have multiple targets and some of them use different app names then you will want to create a separate directory for the InfoPlist.strings file. You will then need to create a separate InfoPlist.strings file for each app name and associate it with the correct target.
  • Select the newly created InfoPlist.strings file and add the following key, value pairs:
"CFBundleDisplayName" = "Your App Name";    // App name as displayed below app icon
"CFBundleName" = "Your App Name"; // Short app name, should be 16 characters or less