Skip to content

Instantly share code, notes, and snippets.

@Slokh
Slokh / script.py
Last active January 24, 2022 22:02
from api.lib.tasks.index_objects import index_objects
from api.lib.utils.list_utils import chunks
from api.lib.utils import get_logger
logger = get_logger()
start = datetime(2021, 11, 30, 17, 0)
end = datetime(2021, 11, 30, 17, 50)
asset_ids_created = AssetEvent.objects.using(settings.DB_REPLICA_LONG_QUERIES).filter(event_timestamp__gte=start, event_timestamp__lte=end, event_type="created").order_by('total_price').values('asset_id').distinct()
@bergmannjg
bergmannjg / rearct-native-app-in-wsl2.md
Last active May 12, 2024 22:33
Building a react native app in WSL2
@coltenkrauter
coltenkrauter / fix-wsl2-dns-resolution
Last active May 17, 2024 04:53
Fix DNS resolution in WSL2
More recent resolution:
1. cd ~/../../etc (go to etc folder in WSL).
2. echo "[network]" | sudo tee wsl.conf (Create wsl.conf file and add the first line).
3. echo "generateResolvConf = false" | sudo tee -a wsl.conf (Append wsl.conf the next line).
4. wsl --terminate Debian (Terminate WSL in Windows cmd, in case is Ubuntu not Debian).
5. cd ~/../../etc (go to etc folder in WSL).
6. sudo rm -Rf resolv.conf (Delete the resolv.conf file).
7. In windows cmd, ps or terminal with the vpn connected do: Get-NetIPInterface or ipconfig /all for get the dns primary and
secondary.

Application Observability in Kubernetes with Datadog APM and Logging - A simple and actionable example

Last year I shared an example on how to realize application tracing in Kuberntes with Istio and Jaeger. After that, the industry has made some substantial headway on this front and we are seeing more vendor support as a result. At Buffer, since we primarily use Datadog for Kubernetes and application monitoring, it's only fitting to complete the circle with Datadog APM and Logging. I had a chance to create a small example for the team and would very much love to share with the community.

Okay, without further ado, let's dive in!

Installing Datadog agent

First thing first, in order to collect metrics and logs from Kubernetes an Datadog agent has to be installed in the cluster. The Datadog team ma

@jiggneshhgohel
jiggneshhgohel / ssh_config.md
Last active September 8, 2022 00:28
Windows 10 Linux Subsystem SSH-agent issues
Host github.com-jiggneshhgohel
HostName github.com
User git
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_work_gmail
AddKeysToAgent yes


Host csexperimental.abc.com
@benjamincharity
benjamincharity / autonomous.txt
Last active May 17, 2024 22:47
Instructions on how to reset the autonomous desk. This fixes a problem where the desk will not lower (also reportedly fixes incorrectly reported heights).
> Thank you for reaching out to Autonomous! I am sorry to hear that you are having some trouble with your SmartDesk
> but I will be glad to assist. It sounds like your system needs a "hard reset" can I please have you follow these
> steps thoroughly.
Reset Steps:
1. Unplug the desk for 20 seconds. Plug it back in. Wait a full 20 seconds.
2. Press the up and down buttons until the desk lowers all the way and beeps or 20 seconds pass.
3. Release both buttons.
4. Press the down buttons until the desk beeps one more time or 20 seconds pass.
@jbeda
jbeda / 01 Install Unison Linux
Last active September 8, 2023 07:47
Unison install
# linux
UNISON_VERSION=2.48.4
sudo apt-get -y install inotify-tools ocaml-nox build-essential
curl -L https://github.com/bcpierce00/unison/archive/${UNISON_VERSION}.tar.gz | tar zxv -C /tmp
cd /tmp/unison-${UNISON_VERSION}
sed -i -e 's/GLIBC_SUPPORT_INOTIFY 0/GLIBC_SUPPORT_INOTIFY 1/' src/fsmonitor/linux/inotify_stubs.c
make UISTYLE=text NATIVE=true STATIC=true
cp src/unison src/unison-fsmonitor ~/bin
# You should modify your path to include ~/bin
@rjz
rjz / projects_spec.ts
Created September 30, 2016 19:22
Testing with fetch, fetchmock, and TypeScript
// Example of mocking out global `fetch`
//
// Spec works using Jasmine (via Karma) and _either_ tsc or babel.
//
// $ npm install --save-dev fetch-mock whatwg-fetch
//
// If using `tsc`, grab the type definitions as well:
//
// $ typings --save --global dt~fetch-mock dt~whatwg-fetch
@msmfsd
msmfsd / es7-async-await.js
Last active February 4, 2024 17:38
Javascript fetch JSON with ES7 Async Await
// Async/Await requirements: Latest Chrome/FF browser or Babel: https://babeljs.io/docs/plugins/transform-async-to-generator/
// Fetch requirements: Latest Chrome/FF browser or Github fetch polyfill: https://github.com/github/fetch
// async function
async function fetchAsync () {
// await response of fetch call
let response = await fetch('https://api.github.com');
// only proceed once promise is resolved
let data = await response.json();
// only proceed once second promise is resolved
@ramesh4sr
ramesh4sr / DeTour.java
Last active December 10, 2015 08:38
Java DeTour Implementation
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Calculate the detour distance between two different rides. Given four
* latitude / longitude pairs, where driver one is traveling from point A to
* point B and driver two is traveling from point C to point D, write a function
* (in your language of choice) to calculate the shorter of the detour distances