Skip to content

Instantly share code, notes, and snippets.

View candidosales's full-sized avatar
🏠
Focusing

Candido Sales Gomes candidosales

🏠
Focusing
View GitHub Profile
@JesusMurF
JesusMurF / users.js
Created November 16, 2016 10:21
How to encrypt password in Sequelize
import Sequelize from 'sequelize'
import bcrypt from 'bcrypt-nodejs'
import connection from '../config/db'
require('sequelize-isunique-validator')(Sequelize)
let User = connection.define('user', {
firstName: {
type: Sequelize.STRING(50),
allowNull: false,
@deadkff01
deadkff01 / divideWithLogarithms.js
Last active April 18, 2018 18:50
JavaScript divide function without using "/"
// Multiplication and division rules... ((+)*(+)=+) ((-)*(-)=+) ((+)*(-)=-) ((-)*(+)=-)
const multiply = (x, y) => {
let r = Math.exp(Math.log(Math.abs(x)) + Math.log(Math.abs(y))).toFixed(2)
return Number((x < 0 && y < 0) ? r : (x < 0 || y < 0) ? -r : r)
}
const divide = (x, y) => {
return (x === 0) ? 0 : multiply(((multiply(x, y) < 0) ? -1.0 : 1.0), Math.exp(Math.log(Math.abs(x)) - Math.log(Math.abs(y))))
}
@h4h13
h4h13 / NotificationHelper.java
Last active September 3, 2018 20:10
Android Big Picture notification with picasso
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import com.squareup.picasso.Picasso;
import java.io.IOException;
@tianhengzhou
tianhengzhou / paypalshipnow_module.py
Created September 1, 2016 02:26
A script use to add recruiter on LinkedIn
import time
from selenium import webdriver
# from urlparse import urlparse
# from urlparse import parse_qs
from selenium.webdriver.support.ui import WebDriverWait
# from selenium.common.exceptions import NoSuchElementException
# from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
# from selenium.webdriver.common.keys import Keys
@wyyqyl
wyyqyl / fp.java
Created July 7, 2016 08:51
use fingerprint to encrypt and decrypt message
package com.stephen.demo;
import android.Manifest;
import android.annotation.TargetApi;
import android.app.KeyguardManager;
import android.content.Context;
import android.content.pm.PackageManager;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Build;
import android.os.CancellationSignal;
@bobbygrace
bobbygrace / trello-css-guide.md
Last active April 22, 2024 10:15
Trello CSS Guide

Hello, visitors! If you want an updated version of this styleguide in repo form with tons of real-life examples… check out Trellisheets! https://github.com/trello/trellisheets


Trello CSS Guide

“I perfectly understand our CSS. I never have any issues with cascading rules. I never have to use !important or inline styles. Even though somebody else wrote this bit of CSS, I know exactly how it works and how to extend it. Fixes are easy! I have a hard time breaking our CSS. I know exactly where to put new CSS. We use all of our CSS and it’s pretty small overall. When I delete a template, I know the exact corresponding CSS file and I can delete it all at once. Nothing gets left behind.”

You often hear updog saying stuff like this. Who’s updog? Not much, who is up with you?

@hmartiro
hmartiro / zeromq-vs-redis.md
Last active April 14, 2024 20:33
Comparison of ZeroMQ and Redis for a robot control platform

ZeroMQ vs Redis

This document is research for the selection of a communication platform for robot-net.

Goal

The purpose of this component is to enable rapid, reliable, and elegant communication between the various nodes of the network, including controllers, sensors, and actuators (robot drivers). It will act as the core of robot-net to create a standardized infrastructure for robot control.

Requirements:

@rahul100885
rahul100885 / UserProfile.rb
Last active February 12, 2023 18:23
Simple json file upload in rails api
class UserProfile < ActiveRecord::Base
has_attached_file :picture,
styles: {
original: {geometry: '1000x0>'},
thumb: '100x100#',
large: '300x200>',
},
convert_options: {large: "-quality 80 -strip -interlace Plane"},
default_url: "http://s3-ap-southeast-1.amazonaws.com/#{ENV["S3_BUCKET"]}/user_profiles/placeholder.png",
path: (Rails.env == 'test' || Rails.env == 'development') ? ":rails_root/public/images/:class/:id/:style/:filename" : "/:class/:id/:style/:filename",
@tonymtz
tonymtz / gist:d75101d9bdf764c890ef
Last active May 7, 2024 13:07
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@praseodym
praseodym / AESGCMUpdateAAD2.java
Last active June 7, 2021 16:38
JDK8 AES-GCM code example
import javax.crypto.*;
import javax.crypto.spec.GCMParameterSpec;
import java.nio.ByteBuffer;
import java.security.SecureRandom;
import java.util.Arrays;
public class AESGCMUpdateAAD2 {
// AES-GCM parameters
public static final int AES_KEY_SIZE = 128; // in bits