Skip to content

Instantly share code, notes, and snippets.

View iuliaL's full-sized avatar
♾️

Iulia Maria Lungu iuliaL

♾️
View GitHub Profile
@nkrh
nkrh / regex_rename.py
Created January 27, 2018 02:51
Bulk rename with Python
import os, re
path = 'C:/Users/Test/test'
pattern = '^([A-Z]+)\-([0-9]+).*$'
replace = r"\2-\1.mkv"
comp = re.compile(pattern)
for f in os.listdir(path):
full_path = os.path.join(path, f)
if os.path.isfile(full_path):
@ericelliott
ericelliott / frozen-not-immutable.js
Created January 3, 2017 21:35
Frozen, not immutable
const a = Object.freeze({
foo: { greeting: 'Hello' },
bar: 'world',
baz: '!'
});
a.foo.greeting = 'Goodbye';
console.log(`${ a.foo.greeting }, ${ a.bar }${a.baz}`);
@ericelliott
ericelliott / no-timing-dependency.js
Last active April 4, 2022 20:01
Pure functions have no timing dependency issues.
const x = {
val: 2
};
const x1 = x => Object.assign({}, x, { val: x.val + 1});
const x2 = x => Object.assign({}, x, { val: x.val * 2});
console.log(x1(x2(x)).val); // 5
@ericelliott
ericelliott / timing-dependency.js
Created January 3, 2017 00:42
Timing dependency
// With shared state, the order in which function calls are made
// changes the result of the function calls.
const x = {
val: 2
};
const x1 = () => x.val += 1;
const x2 = () => x.val *= 2;
@beeman
beeman / remove-all-from-docker.sh
Created November 15, 2016 03:04
Remove all from Docker
# Stop all containers
docker stop `docker ps -qa`
# Remove all containers
docker rm `docker ps -qa`
# Remove all images
docker rmi -f `docker images -qa `
# Remove all volumes
anonymous
anonymous / flexbox.sass
Created August 1, 2016 15:18
FlexBox mixins (with vendors) and utils
//**************************************************************************************************** [ FLEXBOX ]
=flexbox
display: -webkit-box
display: -moz-box
display: -ms-flexbox
display: -webkit-flex
display: flex
// align flex items along the main axis of the current line of the flex container: flex-start | flex-end | center | space-between | space-around
@gunjanpatel
gunjanpatel / revert-a-commit.md
Last active April 21, 2024 22:10
Git HowTo: revert a commit already pushed to a remote repository

Revert the full commit

Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.

git revert {commit_id}

About History Rewriting

Delete the last commit

Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:

@beaucharman
beaucharman / debounce.js
Last active February 25, 2022 20:35
An ES6 implementation of the debounce function. "Debouncing enforces that a function not be called again until a certain amount of time has passed without it being called. As in 'execute this function only if 100 milliseconds have passed without it being called.'" - CSS-Tricks (https://css-tricks.com/the-difference-between-throttling-and-debounc…
function debounce(callback, wait, immediate = false) {
let timeout = null
return function() {
const callNow = immediate && !timeout
const next = () => callback.apply(this, arguments)
clearTimeout(timeout)
timeout = setTimeout(next, wait)
cd ~/.ssh
ssh-keygen -t rsa
cat id_rsa.pub
copy key
go to BitBucket -> Accounts -> Security -> SSH -> Add key -> Paste key
go to server -> Before we begin, navigate to your repository on the Bitbucket website and copy its SSH URL. This will be in the format git@bitbucket.org:<username>/<repo-name>.git
example: git clone --mirror git@bitbucket.org:<username>/<repo-name>.git
Notice the --mirror flag? As its name implies this flag creates an exact mirror of the source repository, including mapping it’s remote branches. It implies --bare, which means that our repository will not have a working copy.
@irazasyed
irazasyed / homebrew-permissions-issue.md
Last active April 24, 2024 17:07
Homebrew: Permissions Denied Issue Fix (OS X / macOS)

Homebrew Permissions Denied Issues Solution

sudo chown -R $(whoami) $(brew --prefix)/*