Skip to content

Instantly share code, notes, and snippets.

🤠
¯\_(ツ)_/¯

Leo Taifa Merinen leotm

🤠
¯\_(ツ)_/¯
Block or report user

Report or block leotm

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@leotm
leotm / findAndReplace.js
Last active Feb 15, 2020
Node.js - Find and Replace file(s)
View findAndReplace.js
var glob = require('glob');
var fs = require('fs');
var replace = require('replace');
// Find file(s)
glob('fileName.txt', function(err, files) {
if (err) { throw err; }
files.forEach(function(item, index, array) {
console.log(item + ' found');
@leotm
leotm / default_syntax.py
Last active Oct 27, 2019
Sublime Text 3 - Set default syntax
View default_syntax.py
# AppData\Roaming\Sublime Text 3\Packages\User\default_syntax.py
import sublime, sublime_plugin
class DefaultSyntaxCommand(sublime_plugin.EventListener):
def on_new(self, view):
# Replace <Language> with desired default language
# Check in AppData\Local\Sublime Text 3\Cache
view.set_syntax_file('Packages/<Language>/<Language>.tmLanguage')
@leotm
leotm / ovpnAuth.js
Last active Jul 25, 2018
Node.js - Add authentication to OpenVPN (.ovpn) files
View ovpnAuth.js
var fs = require("fs");
var glob = require("glob");
glob('*.ovpn', function (err, files) {
if (err) { throw err; }
files.forEach(function(item,index,array){
// Each .ovpn file will use login.conf containing un and pw
fs.appendFile(item, ' auth-user-pass login.conf', function (err) {});
});
});
@leotm
leotm / gist:d5b44be19b7cea524701dd93bf02c4cf
Created Jul 17, 2018 — forked from paulirish/gist:4158604
Learn JavaScript concepts with recent DevTools features
View gist:d5b44be19b7cea524701dd93bf02c4cf

Learn JavaScript concepts with the Chrome DevTools

Authored by Peter Rybin , Chrome DevTools team

In this short guide we'll review some new Chrome DevTools features for "function scope" and "internal properties" by exploring some base JavaScript language concepts.

Closures

Let's start with closures – one of the most famous things in JS. A closure is a function, that uses variables from outside. See an example:

@leotm
leotm / git-bash-shell-cmd.lnk
Last active Sep 24, 2017
GitHub for Windows - Git Bash shell shortcut
View git-bash-shell-cmd.lnk
Target: C:\Windows\System32\cmd.exe /c ""C:\Users\<User>\AppData\Local\GitHub\<Git folder>\bin\sh.exe" --login -i"
Start in: C:\Users\<User>\Documents\GitHub
@leotm
leotm / restartGhost.sh
Created Sep 21, 2017 — forked from hyharryhuang/restartGhost.sh
Restart Ghost Blog
View restartGhost.sh
sudo service nginx restart
sudo service ghost restart
@leotm
leotm / insta.friendorfollow.com_bulk.js
Created Aug 17, 2015
Instagram - Friend or Follow - Bulk Unfollow/Follow
View insta.friendorfollow.com_bulk.js
// So I wrote this purely to reverse getting hacked
// Resulting in following an extra 800 random people
// Always de-activate third-party tools after API authorisation!
// Enter into your browser console
var items = document.querySelectorAll("#content > div > img");
for (var i = 0; i < items.length; i++) {
// Simulates mouse hover over user images to open tooltips
// (Prevously tried amending the results classes and attributes)
@leotm
leotm / ghost
Created Jul 24, 2017
Original file which worked with HTTPS before went down
View ghost
# /etc/nginx/sites-available/ghost
server {
listen 80;
server_name blog.netsca.pe;
location ~ ^/.well-known {
root /var/www/ghost;
}
@leotm
leotm / remove_letsencrypt_all.sh
Created Jul 12, 2017
Remove all traces of Let's Encrypt
View remove_letsencrypt_all.sh
rm -rf /path/to/your/git/clone/directory
rm -rf ~/.local/share/letsencrypt
rm -rf /etc/letsencrypt
rm -rf /var/log/letsencrypt
rm -rf /var/lib/letsencrypt
rm -rf ~/letsencrypt.log
rm -rf ~/.local/share/letsencrypt
@leotm
leotm / generate-php-redirections.sh
Created Mar 29, 2017
A shell script that creates an associate array and generates prefixed php files that redirect to the matching URLs
View generate-php-redirections.sh
# How to iterate over associate arrays in Bash
# To generate PHP redirection files with prefixes
declare -A array
array["uk"]="https://www.google.co.uk"
array["fi"]="https://www.google.fi"
array["es"]="https://www.google.es"
for i in "${!array[@]}"
You can’t perform that action at this time.