Skip to content

Instantly share code, notes, and snippets.

View mcabreradev's full-sized avatar
🎯
Focusing

Miguelángel Cabrera mcabreradev

🎯
Focusing
View GitHub Profile
// create a bookmark and use this code as the URL, you can now toggle the css on/off
// thanks+credit: https://dev.to/gajus/my-favorite-css-hack-32g3
javascript: (function() {
var styleEl = document.getElementById('css-layout-hack');
if (styleEl) {
styleEl.remove();
return;
}
styleEl = document.createElement('style');
styleEl.id = 'css-layout-hack';
@ArnaudValensi
ArnaudValensi / create-ssl-cert.sh
Created January 9, 2018 09:39
Generate a self signed certificate without passphrase for private key
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 10000 -nodes
@aelkz
aelkz / [FEDORA] gitkraken
Last active November 14, 2023 05:50
How to install gitkraken on Fedora [25,26,27] + launcher icon
#!/bin/bash
# Download GitKraken
wget https://release.gitkraken.com/linux/gitkraken-amd64.tar.gz
# copy the downloaded file into /opt directory
cp gitkraken-amd64.tar.gz /opt/
cd /opt
@jherax
jherax / filterArray.js
Last active May 6, 2024 09:35
Filters an array of objects with multiple match-criteria.
/**
* Filters an array of objects using custom predicates.
*
* @param {Array} array: the array to filter
* @param {Object} filters: an object with the filter criteria
* @return {Array}
*/
function filterArray(array, filters) {
const filterKeys = Object.keys(filters);
return array.filter(item => {
// Returns black or white foreground color depending on the background
var textColor = function (backgroundColor) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(backgroundColor);
if (!result) {
return '#000000';//Happens when not given hex
}
var shade = (parseInt(result[1], 16) + parseInt(result[2], 16) + parseInt(result[3], 16)) / 3;
return shade > 128 ? '#000000' : '#FFFFFF';
}
@guisehn
guisehn / gist:6648c8fdcd1102a22a22
Last active June 2, 2021 11:08 — forked from wrburgess/gist:5528649
Backup Heroku Postgres database and restore to local database

Grab new backup

Command: heroku pg:backups capture -a [app_name]

Download

Command: curl -o latest.dump `heroku pg:backups public-url -a [app_name]`

Restore backup dump into local db

// Get element offset from top of page
function getOffset(el) {
el = el.getBoundingClientRect();
return {
left: el.left + window.scrollX,
top: el.top + window.scrollY
};
};
@subfuzion
subfuzion / curl.md
Last active May 16, 2024 18:04
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@sasxa
sasxa / emitter.service.ts
Created January 2, 2016 05:27
Angular2 Communicating between sibling components
import {Injectable, EventEmitter} from 'angular2/core';
@Injectable()
export class EmitterService {
private static _emitters: { [ID: string]: EventEmitter<any> } = {};
static get(ID: string): EventEmitter<any> {
if (!this._emitters[ID])
this._emitters[ID] = new EventEmitter();
return this._emitters[ID];