Skip to content

Instantly share code, notes, and snippets.

View danguita's full-sized avatar

David Anguita danguita

View GitHub Profile

Quick reference: Math

Data properties

  • Math.E: number ES1

    Euler’s number, base of the natural logarithms, approximately 2.7182818284590452354.

  • Math.LN10: number ES1

@notwaldorf
notwaldorf / list.md
Last active January 13, 2024 11:09
Meownica's packing list

Meownica's packing list

I travel a lot so I'm down to like 30 minutes of packing per any kind of trip. I always bring one carry-on suitcase for any trips up to 2 weeks (that I never check in unless forced) -- I have an Away suitcase because it's got a built-in (removable) battery, and amazing wheels.

🚨

  • 🆔Wallet & Passport
  • 💧Travel water bottle
  • 💳Travel credit cards (don't pay foreign currency fees!)
  • 💳Insurance cards
  • 💵Local currency you have
  • 🚎Local public transport cards
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active June 21, 2024 17:39
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@mrsimo
mrsimo / rewrite.rb
Created June 15, 2017 10:52
Convert all those controller tests to the new Rails 5 syntax
require 'parser/current'
require 'byebug'
class FixGets < Parser::Rewriter
def on_send(node)
receiver_node, method_name, *args = *node
if [:get, :patch, :post, :put, :delete, :mobile_get].include?(method_name)
if args.size > 1 && !args[1].loc.expression.source.include?("xhr: true")
rub = args[1].loc.expression.source

Change the number of REPLICAS to make it easier or harder.

demo

$ bash game.sh
I have launched 2 Pods in a Replica Set, are you quicker eliminating
them than Kubernetes recreating them? Let's see!
@mdibaiee
mdibaiee / github-notifications
Last active January 29, 2020 11:27
GitHub Notifications in i3bar
#!/bin/bash
# put this in your bin directory, e.g. /usr/bin or ~/.local/bin
sleep 20 # update interval
# you have to generate a new ACCESS_TOKEN for yourself here (https://github.com/settings/tokens, you only need "notifications" access) and replace the value
response=$(curl -s https://api.github.com/notifications?access_token=ACCESS_TOKEN)
if [[ $response =~ "{" ]]

Scaling your API with rate limiters

The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.

In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.

Request rate limiter

This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.

@Brainiarc7
Brainiarc7 / skylake-tuning-linux.md
Last active June 12, 2024 04:15
This gist will show you how to tune your Intel-based Skylake, Kabylake and beyond Integrated Graphics Core for performance and reliability through GuC and HuC firmware usage on Linux.

Tuning Intel Skylake and beyond for optimal performance and feature level support on Linux:

Note that on Skylake, Kabylake (and the now cancelled "Broxton") SKUs, functionality such as power saving, GPU scheduling and HDMI audio have been moved onto binary-only firmware, and as such, the GuC and the HuC blobs must be loaded at run-time to access this functionality.

Enabling GuC and HuC on Skylake and above requires a few extra parameters be passed to the kernel before boot.

Instructions provided for both Fedora and Ubuntu (including Debian):

Note that the firmware for these GPUs is often packaged by your distributor, and as such, you can confirm the firmware blob's availability by running: