Skip to content

Instantly share code, notes, and snippets.

@llagerlof
llagerlof / 0_reuse_code.js
Created October 27, 2015 16:35
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@llagerlof
llagerlof / people.csv
Last active September 3, 2020 09:36
CSV example (people.csv)
id name age gender
1 Lawrence 39 M
2 Oliver 25 M
3 Roberta 17 F
4 Bell 70 F
5 Dalek 12 M
6 Andrews 10 M
7 Marty 35 M
8 Anna Lammas 40 F
9 Marcos Vinicius 16 M
@llagerlof
llagerlof / Twitter Cramming.user.js
Created September 27, 2017 18:39 — forked from Prof9/Readme.md
Force enable cramming (280 character tweets) on Twitter. Use TamperMonkey. NOTE: Stops working when you switch pages, refresh to fix. https://twitter.com/Prof9/status/912859110776950784
// ==UserScript==
// @name Twitter Cramming
// @description Force enable cramming (280 character tweets) on Twitter
// @author Prof. 9
// @version 0.1
// @match https://twitter.com/*
// @run-at document-idle
// @namespace prof9.twittercramming
// ==/UserScript==
@llagerlof
llagerlof / trimfile.php
Last active April 11, 2018 16:32
TRIM() file contents (remove all BLANK characters in the begining and end of file: spaces, tabs and newlines, keeping just one newline at the end according to a POSIX rule)
<?php
if ( (!empty($argv[1])) && (file_exists($argv[1])) ) {
$file_contents = file_get_contents($argv[1]);
$new_file_contents = trim($file_contents) . "\n";
if ($file_contents <> $new_file_contents) {
file_put_contents($argv[1], $new_file_contents);
}
}
?>
/*
@llagerlof
llagerlof / settings.json
Last active November 1, 2019 15:22
My Visual Studio Code USER SETTINGS
{
"telemetry.enableCrashReporter": false,
"telemetry.enableTelemetry": false,
"window.title": "${dirty}\\${folderName}\\${activeEditorMedium}",
"window.zoomLevel": 0,
"workbench.editor.openPositioning": "first",
"workbench.startupEditor": "newUntitledFile",
"workbench.colorCustomizations": {
@llagerlof
llagerlof / settings.json
Last active July 17, 2019 16:36
My Visual Studio Code WORKSPACE SETTINGS
{
"_comment": "This files.encoding iso88591 is per-project. You should use utf8.",
"files.encoding": "iso88591",
"files.eol": "\n",
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
@llagerlof
llagerlof / jquery_post_form_upload.htm
Last active August 1, 2018 11:57
How to POST form data with multiple files upload using jQuery
<script type="text/javascript">
// This example expect a json return from receiver_script.php
// Remove unnecessary logs and alerts as needed.
var form_data = new FormData();
form_data.append("first_name", $("#first_name").val());
form_data.append("age", $("#age").val());
var file_data = $("#attachment").prop("files");
$.each(file_data, function (i, file) {
@llagerlof
llagerlof / replace_string_recurse.sh
Created July 6, 2018 16:18
Replace string/text inside files, recursively.
find . -type f -exec sed -i -e 's/find_this/replace_by_this/g' {} \;
@llagerlof
llagerlof / update_fork_from_original_repository.md
Last active July 11, 2018 17:54 — forked from CristinaSolana/gist:1885435
Update a fork from the original repository

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@llagerlof
llagerlof / loop_dom_console_one_line.js
Created July 24, 2018 14:25
Console javascript loop through elements, add class and set attribute value (on line)
var nodes = document.querySelectorAll("h1[style='margin:0px;']"); for(i=0; i<nodes.length; i++) { nodes[i].classList.add("opened"); nodes[i].setAttribute("aria-expanded", "true"); }