Skip to content

Instantly share code, notes, and snippets.

View marydn's full-sized avatar
🦙

Mary De Nóbrega marydn

🦙
View GitHub Profile
@marydn
marydn / wget.sh
Created November 29, 2020 23:43
Download a whole website including assets using wget
#!/bin/sh
wget \
--recursive \
--page-requisites \
--adjust-extension \
--span-hosts \
--convert-links \
--domains gurucall.io \
--no-parent \
@marydn
marydn / AnotherComponent.vue
Created October 2, 2019 12:05
Simple VueJS component that beautifies JSON objects
<template>
<code-printer>
{{ json }}
</code-printer>
</template>
<script>
import CodePrinter from './CodePrinter';
export default {
@marydn
marydn / utils.js
Created September 15, 2019 21:06
Remove accents/diacritics in a string in JavaScript
const str = "Crème Brulée"
str.normalize("NFD").replace(/[\u0300-\u036f]/g, "")
// > "Creme Brulee"
@marydn
marydn / docker-cleanup-resources.md
Created March 6, 2019 07:22 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@marydn
marydn / remove_tweets.py
Last active September 26, 2018 14:58
Delete tweets programmatically. You need to install pip install tweepy.
#!/usr/bin/python
from __future__ import print_function
import tweepy
import itertools
import datetime
# OAuth application
consumer_key = "<<CONSUMER_KEY>>"
consumer_secret = "<<CONSUMER_SECRET>>"
@marydn
marydn / project.local
Created February 26, 2018 08:51
Nginx virtualhost for Symfony2
server {
server_name project.local;
root /var/www/project/web;
location / {
# try to serve file directly, fallback to app.php
try_files $uri /app.php$is_args$args;
}
# DEV
@marydn
marydn / .gitconfig
Created February 8, 2018 11:23
GIT aliases
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --
count-month = shortlog -sne --since="01 Jan 2018" --before="31 Dec 2018"
yolo = !git add -A && git commit -m \"$(curl -s whatthecommit.com/index.txt)\"
clean-local-branches = branch --merged | egrep -v \"(^\\*|master|dev)\" | xargs git branch -d
@marydn
marydn / utils.js
Created June 12, 2017 09:01
Get query params using javascript
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
};
@marydn
marydn / unique_values_multidimensional_array.php
Created October 19, 2016 09:59
One-liner scripts collection
// Remove duplicate values from a multi-dimensional array in PHP
$input = array_map('unserialize', array_unique(array_map('serialize', $input)));
@marydn
marydn / token.php
Created April 26, 2014 16:19
Generate token
<?php
// 32-byte length
$token = md5(uniqid(mt_rand(), true));
// 256
$token = bin2hex(mcrypt_create_iv(128, MCRYPT_DEV_RANDOM));