Skip to content

Instantly share code, notes, and snippets.

@EmperorEarth
EmperorEarth / GolangCPUProfiles.sh
Created March 4, 2019 11:20 — forked from bgadrian/GolangCPUProfiles.sh
Golang Flame graph profiles
#install FlameGraph library
cd /opt/
sudo git clone https://github.com/brendangregg/FlameGraph.git
#make it accesible from any folder
vim ~/.bashrc
##add these lines anywhere and exit vim (if you can)
export FLAMEPATH=/opt/FlameGraph
PATH=$PATH:$FLAMEPATH
@EmperorEarth
EmperorEarth / valuer.go
Created March 6, 2019 14:56 — forked from jmoiron/valuer.go
Example uses of sql.Scanner and driver.Valuer
package main
import (
"bytes"
"compress/gzip"
"database/sql/driver"
"errors"
"fmt"
"github.com/jmoiron/sqlx"
_ "github.com/mattn/go-sqlite3"
@EmperorEarth
EmperorEarth / keyrepeat.shell
Created May 26, 2019 12:44 — forked from kconragan/keyrepeat.shell
Enable key repeat in Apple Lion for Sublime Text in Vim mode
# Mac OS X Lion introduced a new, iOS-like context menu when you press and hold a key
# that enables you to choose a character from a menu of options. If you are on Lion
# try it by pressing and holding down 'e' in any app that uses the default NSTextField
# for input.
#
# It's a nice feature and continues the blending of Mac OS X and iOS features. However,
# it's a nightmare to deal with in Sublime Text if you're running Vintage (Vim) mode,
# as it means you cannot press and hold h/j/k/l to move through your file. You have
# to repeatedly press the keys to navigate.
@EmperorEarth
EmperorEarth / install_nodejs_and_yarn_homebrew.md
Created June 12, 2019 22:50 — forked from nijicha/install_nodejs_and_yarn_homebrew.md
Install NVM, Node.js, Yarn via Homebrew

Install NVM, NodeJS, Yarn via Homebrew

Prerequisites

  • Homebrew should be installed (Command line tools for Xcode are included).

Getting start

Install NVM and NodeJS

  1. Install nvm via Homebrew
const createMySocketMiddleware = (url) => {
return storeAPI => {
let socket = createMyWebsocket(url);
socket.on("message", (message) => {
storeAPI.dispatch({
type : "SOCKET_MESSAGE_RECEIVED",
payload : message
});
});
@EmperorEarth
EmperorEarth / material_design_guidelines_dimens.xml
Created July 2, 2019 21:56 — forked from aeroechelon/material_design_guidelines_dimens.xml
Recommended Material Design Dimensions for Android
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--
# Material Design Dimensions
These dimensions are provided as per Material Design Guidelines
to adhere to a 8 dp baseline grid. (With the exception of the
toolbar and notification bar.).
## References
@EmperorEarth
EmperorEarth / text-height-measurer.js
Created July 8, 2019 12:24 — forked from Ashoat/text-height-measurer.js
React Native component for measuring text height
// @flow
import type {
StyleObj,
} from 'react-native/Libraries/StyleSheet/StyleSheetTypes';
import React from 'react';
import PropTypes from 'prop-types';
import { Text, View, StyleSheet } from 'react-native';
import invariant from 'invariant';
@EmperorEarth
EmperorEarth / class.js
Created July 20, 2020 01:53
Color picker learning example
import React from "react";
class App extends React.Component {
render() {
const { redIntensity, greenIntensity, blueIntensity } = this.state;
const { _setRedIntensity, _setGreenIntensity, _setBlueIntensity } = this;
return (
<div style={{ display: "flex", flexDirection: "row" }}>
<div
style={{
@EmperorEarth
EmperorEarth / Chat.js
Last active July 26, 2020 17:02
learn-react-component-state
import React from "react";
class App extends React.Component {
render() {
return (
<div style={{ display: "flex", flexDirection: "row" }}>
<Status />
<Conversation />
</div>
);
import React from "react";
import { Button, Text, View } from "react-native";
class App extends React.Component {
render() {
const remaining = this.state.deadline - this.state.now;
const minutes = Math.floor(remaining / 60000);
const seconds = Math.round((remaining - minutes * 60000) / 1000);
return (
<View style={{ padding: 10 }}>