Skip to content

Instantly share code, notes, and snippets.

View wilomgfx's full-sized avatar
🧙‍♂️
Focus pocus

William Cantin wilomgfx

🧙‍♂️
Focus pocus
View GitHub Profile
// ES6, React 0.14
var MenuItem = ({onClick, text, active}) => (
<button onClick={onClick} style={active? {color: 'red'} : null}>{text}</button>
);
// example of use: <MenuBar buttons={['cat', 'dog', 'penguin']}/>
class MenuBar extends React.Component {
constructor(props) {
super(props);
this.state = {activeIndex: 0};
@wilomgfx
wilomgfx / preview-an-image-before-it-is-uploaded.js
Created April 12, 2017 03:41
preview-an-image-before-it-is-uploaded
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#blah').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
@wilomgfx
wilomgfx / lookForUpperOrLowerCaseInString.js
Last active June 7, 2020 16:56
Helper to check if a string contains an uppercase or lowercase char
function hasLowerCase(str) {
if(str.toUpperCase() != str) {
return true;
}
return false;
}
function hasUpperCase(str) {
if(str.toLowerCase() != str) {
return true;
@wilomgfx
wilomgfx / extract_realm_database_android.sh
Last active April 11, 2017 16:28 — forked from jk2K/extract_realm_database_android.sh
how to export realm database, work on Android 5.0+
#!/bin/bash
ADB_PATH="/Users/${USER}/Library/Android/sdk/platform-tools"
PACKAGE_NAME="com.yourcompany.app"
DB_NAME="default.realm"
DESTINATION_PATH="/Users/${USER}/Downloads/${DB_NAME}"
NOT_PRESENT="List of devices attached"
ADB_FOUND=`${ADB_PATH}/adb devices | tail -2 | head -1 | cut -f 1 | sed 's/ *$//g'`
if [[ ${ADB_FOUND} == ${NOT_PRESENT} ]]; then
echo "Make sure a device is connected"
else
export function isObject(item) {
return (item && typeof item === 'object' && !Array.isArray(item) && item !== null);
}
export default function mergeDeep(target, source) {
let output = Object.assign({}, target);
if (isObject(target) && isObject(source)) {
Object.keys(source).forEach(key => {
if (isObject(source[key])) {
if (!(key in target))
@wilomgfx
wilomgfx / appify.sh
Last active February 8, 2017 16:59 — forked from oubiwann/appify.sh
appify — create the simplest possible Mac app from a shell script (adds an application icon)
#!/usr/bin/env bash
VERSION=4.0.1
SCRIPT=`basename "$0"`
APPNAME="My App"
APPICONS="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/GenericApplicationIcon.icns"
OSX_VERSION=`sw_vers -productVersion`
PWD=`pwd`
function usage {
@wilomgfx
wilomgfx / reactComponent(Jetbrains File Template).jsx
Last active October 20, 2017 21:36
This is my base template for a React Component
//Created by ${USER} on ${DATE}.
import React, { Component } from 'react';
import PropTypes from 'proptypes';
export default class ${NAME} extends Component {
constructor(props) {
super(props);
}
render() {
return (
@wilomgfx
wilomgfx / reactNativeComponent(JetBrains File Template).js
Last active October 20, 2017 21:36
This is my base file template for a react-native component
//Created by ${USER} on ${DATE}.
import React, { Component } from 'react'
import PropTypes from 'proptypes';
import {
View,
StyleSheet
}from 'react-native'
export default class ${NAME} extends Component {
constructor(props) {
@wilomgfx
wilomgfx / .zshrc
Last active July 29, 2019 20:31
My Zshrc file for macOs
# If you come from bash you might have to change your $PATH.
#export PATH=$HOME/bin:/usr/local/bin:$PATH
#z
. /usr/local/etc/profile.d/z.sh
fpath=(/usr/local/share/zsh-completions $fpath)
#export yarn global path
export PATH="$PATH:`yarn global bin`"
@wilomgfx
wilomgfx / cloudSettings
Last active February 24, 2020 16:37
Visual Studio Code Sync Settings GIST
{"lastUpload":"2020-02-24T16:37:23.439Z","extensionVersion":"v3.4.3"}