Skip to content

Instantly share code, notes, and snippets.

View superhero's full-sized avatar
💭
oɹǝɥɹǝdns

Erik Landvall superhero

💭
oɹǝɥɹǝdns
View GitHub Profile
@superhero
superhero / charset-converter.php
Last active April 23, 2024 06:14
UTF-8 Encoding Debugging
<?php
$search = array(
'á',
'ä',
'Ä',
'ç',
'é',
'É',
@superhero
superhero / README.md
Last active September 2, 2021 13:46
When docker swarm fucks with you

From a new installation

sudo usermod -aG docker $USER

Adding your user to the docker group. OBS! Follow up with a login-logout process of the session.


From a manager node

# settig default permissions, r/rw to your user and your default group
umask 0002
# return if not running interactively
[ -z "$PS1" ] && return
# don't put duplicate lines or lines starting with space in the history
HISTCONTROL=ignoreboth:erasedups
# ignores placing the exit command in history
@superhero
superhero / mysql-cheat-sheet.sql.md
Last active March 10, 2018 09:38
MySQL cheat sheet

Select

CSV file

SELECT * FROM `tbl`
INTO OUTFILE '/tmp/out.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
@superhero
superhero / git.md
Last active August 8, 2017 15:18
Git commands...

remove last commit from git and github

git push -f origin HEAD^:master

sudo apt-get install make
sudo apt-get install php5
sudo apt-get install php5-dev
sudo apt-get install php-pear
sudo apt-get install libyaml-dev
sudo pecl install yaml-1.1.0
@superhero
superhero / git-commit-push.sh
Created December 22, 2016 16:28
run in root of multiple projects to commit and push them all at once
#!/bin/bash
# note that all commits will have the same commit message
if [ $# -eq 1 ]; then
MSG=$1
else
read -p "commit message: " MSG
fi
for d in */ ; do
@superhero
superhero / npm-publish.sh
Created December 22, 2016 16:25
run in root folder of multiple npm packages to publish them all with 1 command
#!/bin/bash
docker run \
-it \
--rm \
--volume /etc/localtime:/etc/localtime:ro \
--volume `pwd`/.npmrc:/root/.npmrc \ # notice the login credentials that needs to be mounted
--volume `pwd`:/app \
--workdir /app \
node /bin/bash -c "
@superhero
superhero / math.random.seed.js
Created November 25, 2016 10:49
A seeded random generator
(seed) =>
{
const n = Math.sin(seed);
return n - Math.floor(n);
};
@superhero
superhero / auto-expand-textarea.js
Last active March 2, 2016 14:56
Expands the textarea depending on content
(function($)
{
$(document).on('input', 'textarea', function()
{
var $this = $(this);
var padTop = parseInt($this.css('padding-top'), 10);
var padBot = parseInt($this.css('padding-bottom'), 10);
$this.height(0);
var scroll = $this.prop('scrollHeight');
$this.height(scroll - padTop - padBot);