Skip to content

Instantly share code, notes, and snippets.

View armand1m's full-sized avatar

Armando Magalhães armand1m

View GitHub Profile
@armand1m
armand1m / webkit-white-bg-autofill-hack.css
Created March 12, 2017 17:26
Removes webkit autofills horrible yellow color.
# Thanks to http://stackoverflow.com/questions/2781549/removing-input-background-colour-for-chrome-autocomplete
input:-webkit-autofill, textarea:-webkit-autofill, select:-webkit-autofill {
box-shadow: 0 0 0px 1000px white inset;
-webkit-box-shadow: 0 0 0px 1000px white inset;
}
@armand1m
armand1m / geo.js
Created February 3, 2017 01:34 — forked from mkhatib/geo.js
A Javascript utility function to generate number of random Geolocations around a center location and in a defined radius.
/**
* Generates number of random geolocation points given a center and a radius.
* @param {Object} center A JS object with lat and lng attributes.
* @param {number} radius Radius in meters.
* @param {number} count Number of points to generate.
* @return {array} Array of Objects with lat and lng attributes.
*/
function generateRandomPoints(center, radius, count) {
var points = [];
for (var i=0; i<count; i++) {
@armand1m
armand1m / logger.js
Created January 27, 2017 03:18
Helpful Logger using Squeak.js
'use strict'
const Squeak = require('squeak')
const logger = new Squeak()
.type('sync', {
color: 'cyan',
prefix: '+ sync'
})
.type('event', {
@armand1m
armand1m / .editorconfig
Created January 27, 2017 03:15
node.js .editorconfig file
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
@armand1m
armand1m / prepare-git-env.sh
Created December 1, 2016 16:23
One way of using Git on Rancher OS
alias git="docker run -ti --rm -v $(pwd):/git bwits/docker-git-alpine"
@armand1m
armand1m / Dockerfile
Last active March 10, 2024 14:54
Yarn cache compatible Dockerfile
FROM alpine
RUN apk add --update --no-cache nodejs
RUN npm i -g yarn
ADD package.json yarn.lock /tmp/
ADD .yarn-cache.tgz /
RUN cd /tmp && yarn
RUN mkdir -p /service && cd /service && ln -s /tmp/node_modules
@armand1m
armand1m / Dockerfile
Created November 1, 2016 16:31 — forked from alexellis/base.Dockerfile
Docker swarm service to mine into the Nice Hash pool
# Published on Docker Hub with above user alexellisio.
# If you want to rebuild your own copy, follow below instructions
# Build this on each type of machine so you have the correct CPU extensions.
FROM ubuntu:latest
WORKDIR /root/
RUN apt-get update -qy && \
apt-get install -qy cmake build-essential libboost-all-dev git ca-certificates \
--no-install-recommends
@armand1m
armand1m / sequelize-bulk-upsert.js
Created October 18, 2016 14:22
A bulkUpsert function using Promises and the Sequelize API
module.exports = function bulkUpsert(model, key, values) {
function _find(where) {
return model.findOne({ where })
}
function _update(value, where) {
return model
.update(value, { where })
.then(() => _find(where))
}
@armand1m
armand1m / shipping_country_snippet.php
Created October 11, 2016 03:08
woocommerce snippet
<?php
function wc_get_country() {
$_country = WC()->customer->get_country();
if ( $_country !== WC()->customer->get_shipping_country() && 'shipping' === get_option('wc_price_based_country_based_on', 'billing') ) {
$_country = WC()->customer->get_shipping_country();
}
@armand1m
armand1m / disk-usage-panel.sh
Last active October 15, 2016 14:34
terminal disk usage panel
# when there is no watch command
while [ 0 -lt 10 ]; do clear; df -h; sleep 1; done
# if watch is available
watch -n 1 df -h