Skip to content

Instantly share code, notes, and snippets.

View andho's full-sized avatar

Amjad Mohamed andho

View GitHub Profile
@tknv
tknv / .mbsyncrc
Last active June 16, 2022 20:17
isync office365
IMAPAccount work
Host outlook.office365.com
User [email protected]
PassCmd "pass mail/work-gpg"
UseIMAPS yes
CertificateFile /etc/ssl/certs/ca-certificates.crt
IMAPStore work-remote
Account work
@Samgarr
Samgarr / prom_updates.cron
Created October 27, 2016 18:51
Monitoring debian security updates with Prometheus Textfile collector. Don't forget run node_exporter with appropriate parameters!
# based on https://www.robustperception.io/monitoring-directory-sizes-with-the-textfile-collector/
33 * * * * unattended-upgrade --dry-run -d 2> /dev/null | grep 'Checking' | wc -l | sed -ne 's/^\([0-9]\+\).*$/security_updates_count \1/p' > /var/lib/node_exporter/textfile_collector/security_updates_count.prom.$$ && mv /var/lib/node_exporter/textfile_collector/security_updates_count.prom.$$ /var/lib/node_exporter/textfile_collector/security_updates_count.prom
@Restuta
Restuta / the-bind-problem.jsx
Last active March 16, 2024 00:22
React, removeEventListener and bind(this) gotcha
/* Sometimes it's pretty easy to run ito troubles with React ES6 components.
Consider the following code: */
class EventStub extends Component {
componentDidMount() {
window.addEventListener('resize', this.onResize.bind(this)); //notice .bind
}
componentWillUnmount() {
window.removeEventListener('resize', this.onResize.bind(this));
@olasd
olasd / stream_to_youtube.sh
Created March 28, 2014 19:58
Stream video to youtube via ffmpeg
#! /bin/bash
#
# Diffusion youtube avec ffmpeg
# Configurer youtube avec une résolution 720p. La vidéo n'est pas scalée.
VBR="2500k" # Bitrate de la vidéo en sortie
FPS="30" # FPS de la vidéo en sortie
QUAL="medium" # Preset de qualité FFMPEG
YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2" # URL de base RTMP youtube
@gregoryyoung
gregoryyoung / gist:1500720
Created December 20, 2011 08:00
Greg's Stop Loss Kata
Greg's Stop Loss Kata
Testing is very hard when time is involved ...
A trailing stop loss is a term used in financial trading. For a very in depth explanation you can read here http://www.investopedia.com/articles/trading/03/080603.asp and http://en.wikipedia.org/wiki/Order_(exchange)#Stop_orders
However we do not need a huge amount of background in order to do the kata as we are going to limit the problem a bit.
The general idea is that when you buy into a stock at a price say $10. You want it to automatically get sold if the stock goes below $9 (-$1). If we use the term "trailing" that means that id the price goes up to $11 then the sell point becomes $10.
<?php
error_reporting(E_ALL | E_STRICT);
/**
* To runs this example you will need the UUID PHP Extension http://pecl.php.net/package/uuid
*/
/**
* DomainModel Aggregate root for a Tweet
*
* The Aggregate root tracks all uncommitted events and can have old
* events replayed to it.