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 / 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 / findAndReplace.js
Last active Sep 26, 2018
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 / delete.js
Last active Aug 29, 2015
Node.js - Delete file(s)
View delete.js
var glob = require('glob');
var fs = require('fs');
// Find file(s)
glob('**/fileName.ext', function(err, files) {
if (err) { throw err; }
files.forEach(function(item, index, array) {
console.log(item + ' found');
// Delete file(s)
fs.unlink(item, function(err) {
@leotm
leotm / rename.js
Last active Aug 29, 2015
Node.js - Rename file(s)
View rename.js
var glob = require('glob');
var fs = require('fs');
// Find file(s)
glob('fileName.ext', function(err, files) {
if (err) { throw err; }
// Check for file(s)
if (Boolean(files.length)) {
files.forEach(function(item, index, array) {
var newItem = item.replace('regexp', 'replacement');
@leotm
leotm / append.js
Last active Aug 29, 2015
Node.js - Append regexp to file(s)
View append.js
var glob = require('glob');
var fs = require('fs');
// Find file(s)
glob('fileName.ext', function(err, files) {
if (err) { throw err; }
files.forEach(function(item, index, array) {
console.log(item + ' found.');
// Read file(s)
var file = fs.readFileSync(item, 'utf8');
@leotm
leotm / .jscsrc
Last active Aug 29, 2015
JSCS - JavaScript Code Style - Rules
View .jscsrc
{
"jscsVersion": "2.0.0",
"preset": "google",
"fileExtensions": [".js", "jscs"],
"validateQuoteMarks": true,
"requireParenthesesAroundIIFE": true,
"maximumLineLength": 120,
"validateLineBreaks": "LF",
@leotm
leotm / getLinks.js
Last active Aug 29, 2015
Get all links from website
View getLinks.js
@leotm
leotm / getLinks.js
Last active Aug 29, 2015
Download all links from website
View getLinks.js
@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 / ovpnSort.js
Last active Feb 5, 2016
Node.js - IPVanish - OpenVPN - Sort .ovpn config files into folders by Country
View ovpnSort.js
// This will sort all IPVanish config/.ovpn files (e.g. ipvanish-BE-Brussels-bru-b01.ovpn)
// into respective folders (e.g. ipvanish-BE)
var glob = require('glob');
var fs = require('fs');
glob('*.ovpn', function(err, files) {
if (err) { throw err; }
files.forEach(function(item, index, array) {
// Create the folders
You can’t perform that action at this time.