Skip to content

Instantly share code, notes, and snippets.

@kalkulus
kalkulus / gist:f15c3d080031d5cc803a94af133a8745
Created January 23, 2019 13:18
Add already commited file to .gitignore
- Edit .gitignore to match the file you want to ignore
- git rm --cached /path/to/file
== HTML
<div class="wrapper">
<div class="content"></div>
</div>
== CSS
.wrapper {
position: absolute;
}
@kalkulus
kalkulus / slugify.js
Last active November 22, 2017 13:18
js slugify text
// from https://gist.github.com/kalkulus/5d536faba9a6d4d8c0413a5989cd46ac
const utf2ascii = (text) => {
const combining = /[\u0300-\u036F]/g;
return str.normalize('NFKD').replace(combining, ''));
};
const slugify = (text) => {
let st = text.toLowerCase();
st = utf2ascii(st);
st = st.replace(/[^a-z0-9 ]+/gi,'');
@kalkulus
kalkulus / utf8-to-ascii.js
Created November 22, 2017 13:15
UTF-8 to ASCII conversion
// source https://stackoverflow.com/a/23633988
const str = "üó";
const utf2ascii = (text) => {
const combining = /[\u0300-\u036F]/g;
return str.normalize('NFKD').replace(combining, ''));
};
https://stackoverflow.com/questions/37420642/how-to-undo-the-last-commit-in-git
git reset HEAD^
This will bring the dir to state before you've made the commit, HEAD^ means the parent of the current commit
(the one you don't want anymore), while keeping changes from it (unstaged).
=====
https://nakkaya.com/2009/09/24/git-delete-last-commit/
git config --global credential.helper cache
# Set git to use the credential memory cache
git config --global credential.helper 'cache --timeout=3600'
# Set the cache to timeout after 1 hour (setting is in seconds)
@kalkulus
kalkulus / gist:0c89be6b2e3270802137940be48851cb
Last active October 4, 2016 16:54
git add branch, track remote
git checkout -b newBranchName
git branch --set-upstream-to=origin/newBranchName newBranchName
OR
git push -u origin newBranchName
// Node.js CheatSheet.
// Download the Node.js source code or a pre-built installer for your platform, and start developing today.
// Download: http://nodejs.org/download/
// More: http://nodejs.org/api/all.html
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
@kalkulus
kalkulus / gist:7d9a1c21bdde0fe8b182
Created August 21, 2015 07:49
copy directory structure from one folder to the other, without the files
cd /path/to/directories && find . -type d -exec mkdir -p -- /path/to/backup/{} \;
@kalkulus
kalkulus / gist:e222bb5a4a899f72e13f
Created January 28, 2015 16:27
Get YAML file in a flat structure with joined keys
use Symfony\Component\Yaml\Yaml;
function flattenKeys($data, $parent = ''){
$result = array();
if (!is_array($data)) {
return $result;
}
foreach ($data as $key => $value) {