Skip to content

Instantly share code, notes, and snippets.

View CTimmerman's full-sized avatar
💭
Amazed at Microsoft's poor UX.

Cees Timmerman CTimmerman

💭
Amazed at Microsoft's poor UX.
View GitHub Profile
@anshumanb
anshumanb / from-guest.sh
Last active July 2, 2024 10:27
Disable and enable VirtualBox guest-host time sync
# Disable time sync from guest
/etc/init.d/vboxadd-service stop
# Enable time sync from guest
/etc/init.d/vboxadd-service start
@bgusach
bgusach / multireplace.py
Last active December 10, 2024 03:51
Python string multireplacement
def multireplace(string, replacements, ignore_case=False):
"""
Given a string and a replacement map, it returns the replaced string.
:param str string: string to execute replacements on
:param dict replacements: replacement dictionary {value to find: value to replace}
:param bool ignore_case: whether the match should be case insensitive
:rtype: str
"""
@Faheetah
Faheetah / Jenkinsfile.groovy
Last active October 7, 2025 15:42
Jenkinsfile idiosynchrasies with escaping and quotes
node {
echo 'Results included as an inline comment exactly how they are returned as of Jenkins 2.121, with $BUILD_NUMBER = 1'
echo 'No quotes, pipeline command in single quotes'
sh 'echo $BUILD_NUMBER' // 1
echo 'Double quotes are silently dropped'
sh 'echo "$BUILD_NUMBER"' // 1
echo 'Even escaped with a single backslash they are dropped'
sh 'echo \"$BUILD_NUMBER\"' // 1
echo 'Using two backslashes, the quotes are preserved'
sh 'echo \\"$BUILD_NUMBER\\"' // "1"
@JohannesHoppe
JohannesHoppe / settings.json
Created May 18, 2016 12:04
VSCode: proxy settings
// VSCode: Place your settings in this file to overwrite the default settings
{
"http.proxy": "http://user:[email protected]:8080",
"https.proxy": "http://user:[email protected]:8080",
"http.proxyStrictSSL": false
}
@gunjanpatel
gunjanpatel / revert-a-commit.md
Last active September 20, 2025 22:27
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:

@mickeypash
mickeypash / game-of-life.py
Created July 10, 2016 10:20
Conway's Really Simple Game of Life based on ("Stop Writing Classes" PyCon 2012)[https://www.youtube.com/watch?v=o9pEzgHorH0]
import itertools
# Conway's Really Simple Game of Life based on "Stop Writing Classes" PyCon 2012
def neighbors(point):
x,y = point
yield x + 1, y
yield x - 1, y
yield x, y + 1
yield x, y - 1
@CTimmerman
CTimmerman / bookmarklets.js
Last active October 23, 2025 11:37
Bookmarklets / Favelets - Drag to bookmarks bar and rename, then click on page to affect.
// Remove body handlers for WYSIWYG copy/drag for example from this site. Does break this textinput.
javascript:(()=>{let e = document.body; e.parentNode.replaceChild(e.cloneNode(true), e)})()
// Speed up / slow down HTML5 videos! Just set as URLs of bookmark bar items:
javascript:(function(){v = []; for(x of document.querySelectorAll("audio, video")) v.push(x); try{v.push(window.frames[0].document.querySelector("audio, video"))}catch(ex){}; for(i of v) i.playbackRate += .4}())
javascript:(function(){v = []; for(x of document.querySelectorAll("audio, video")) v.push(x); try{v.push(window.frames[0].document.querySelector("audio, video"))}catch(ex){}; for(i of v) i.playbackRate -= .4}())
// Dark mode
javascript:(() => { let ok = false; for (let i = 0; i < 100; ++i) { try { let s = document.styleSheets[i]; s.insertRule("* {background-color: #000b!important; color: #FFF!important; text-shadow: 0 0 1em #fff}", s.cssRules.length); ok = true; break } catch (ex) { console.log("Dark Mode " + ex) } } if (!ok) { let s
@CTimmerman
CTimmerman / Tech prefs.md
Last active October 25, 2025 20:07
Technology preferences / tech prefs.

My Technology Preferences

For those who don't bother to remember.

Hardware

In recent years, it takes about 10 years to apply a discovery in a new field (e.g. "laptop batteries" in electric cars, down from 105 in case of radio's 1885 patent vs 1780 discovery, but it should be noted that electric cars like the 1914 Detroit Electric Model 47 Brougham worked just fine for city trips), 10 years to get it ready for mass production (e.g. Tesla), and 10 years to make it affordable to normal people (again Tesla).

Personal Computer

@fgilio
fgilio / axios-catch-error.js
Last active June 18, 2025 11:09
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@CTimmerman
CTimmerman / simple_git_workflow.md
Last active October 23, 2025 13:23
Simple git workflow/guide.
  1. Install Git distributed version control software.
  2. Set up your default credentials (or display without a value to set):
$ git config --global user.name "John Doe"
$ git config --global user.email [email protected]

or if he's a GitHub user, so you see his icon: [email protected]

For example on MacOS: