Skip to content

Instantly share code, notes, and snippets.

View dideler's full-sized avatar

Dennis Ideler dideler

View GitHub Profile
@dideler
dideler / bitwise-operators.md
Created April 12, 2012 08:25
Bitwise tricks

Inspired by this article. Neat tricks for speeding up integer computations.

Note: cin.sync_with_stdio(false); disables synchronous IO and gives you a performance boost. If used, you should only use cin for reading input (don't use both cin and scanf when sync is disabled, for example) or you will get unexpected results.

Multiply by a power of 2

x = x << 1; // x = x * 2

@dideler
dideler / bot.rb
Last active September 24, 2024 18:18
Sending a notification message to Telegram using its HTTP API via cURL
# Use this script to test that your Telegram bot works.
#
# Install the dependency
#
# $ gem install telegram_bot
#
# Run the bot
#
# $ ruby bot.rb
#
@dideler
dideler / twitter-gadget-instructions.md
Last active September 20, 2024 08:42
Twitter Gadget for Google Sites

How to display a Twitter feed on your Google Site

A short tutorial for creating a Twitter gadget for Google Sites that will display tweets from a user or search.

Problem

Displaying Twitter tweets on your Google Sites website is difficult!
Google Sites filters your HTML code and doesn't allow you to add your own JavaScript code, therefore restricting you from adding any of the many existing Twitter widgets that exist today, including Twitter's very own.

The Google Gadgets directory contains a Twitter gadget called Twit. This is the gadget I was using in the past.

@dideler
dideler / example.md
Last active September 13, 2024 09:55
A python script for extracting email addresses from text files.You can pass it multiple files. It prints the email addresses to stdout, one address per line.For ease of use, remove the .py extension and place it in your $PATH (e.g. /usr/local/bin/) to run it like a built-in command.

The program below can take one or more plain text files as input. It works with python2 and python3.

Let's say we have two files that may contain email addresses:

  1. file_a.txt
foo bar
ok ideler.dennis@gmail.com sup
 hey...user+123@example.com,wyd
hello world!
@dideler
dideler / bootstrapping.md
Last active August 22, 2024 17:34
Bootstrapping - a list of useful resources to get up and running quickly

Welcome!

UPDATE: This list is no longer maintained. I've moved it to its own repo so you can send suggestions as Pull Requests. https://github.com/dideler/bootstrapping/

For feedback or suggestions, please send a tweet (@dideler). Gist comments don't notify me. Pull requests aren't possible with gists (yet), so I don't recommend forking because then I can't easily get the change.

Starring this gist will give me an idea of how many people consider this list useful.

@dideler
dideler / inheritance.cpp
Last active August 9, 2024 12:25
C++ notes
class A
{
public:
int x;
protected:
int y;
private:
int z;
};
@dideler
dideler / 0-startup-overview.md
Last active August 7, 2024 12:55
Startup Engineering notes
@dideler
dideler / code_review_checklists.md
Last active July 23, 2024 05:43
Code review checklists. Leave your suggestions in a comment below!

Based on the article: Using checklists for code review

In general, people are pretty good at the code review process, but it's sometimes surprising what can slip through. A natural consequence of the way our brains look at the world is that it's easy to pay a lot of attention to small details and code style flubs, and completely miss the big picture.

Obviously, not everything is applicable for every change. If the review request isn't making any changes to UI, then skip the first two checklists entirely. If a change is a bug fix, typically don't review it for architecture and design principles.

Put the big stuff first (e.g. architecture). You don't want to work through a ton of small issues before realizing that everything has to be rewritten.

Do a pass through the code for each and every item in the checklist. By only looking for a very specific type of defect, each pass goes relatively quickly, even for large changes. Focu

@dideler
dideler / css.md
Last active July 9, 2024 21:39
CSS Tips

Vertical centering

position: absolute;
top: 50%;
transform: translateY(-50%);

Translate is processed at the end, meaning it is based on the final element height. This means it works with any element, even dynamic heights. Of course it only works on relatively new browsers, but translate is well accepted and on the path to being ubiquitous. The style is also easy to understand and isn't hacky.

@dideler
dideler / you-cant-win-an-argument.md
Last active May 23, 2024 12:44
People skills. Excerpts from "How to win friends and influence people"

The raconteur mentioned that the quotation was from the Bible. He was wrong. I knew that, I knew it positively. There couldn't be the slightest doubt about it. And so, to get a feeling of importance and display my superiority, I appointed myself as an unsolicited and unwelcome committee of one to correct him. He stuck to his guns.

What? From Shakespeare? Impossible! Absurd! That quotation was from the Bible. And he knew it.

The storyteller was sitting on my right; and Frank Gammond, an old friend of mine, was seated at my left. Mr. Gammond had devoted years to the study of Shakespeare, So the storyteller and I agreed to submit the question to Mr. Gammond. Mr. Gammond listened, kicked me under the table, and then said: "Dale, you are wrong. The gentleman is right. It is from the Bible."

On our way home that night, I said to Mr. Gammond: "Frank, you knew that quotation was from Shakespeare,"

"Yes, of course," he replied, "Hamlet, Act Five, Scene Two. But we were guests at a festive occasion, my dear Dale. W