Skip to content

Instantly share code, notes, and snippets.

View davideuler's full-sized avatar

david l euler davideuler

  • dianping.com
  • Shanghai, China
View GitHub Profile
@davideuler
davideuler / gist:5476917
Created April 28, 2013 13:44
互联网工程师文化
@davideuler
davideuler / gist:5477241
Last active December 16, 2015 18:20
阅读书单
设计原本
黑客与画家
代码质量
技术领导之路
布道之道
rework
创业者手册
深入理解计算机网络
#!/usr/bin/python
# -*- encoding: UTF-8 -*-
import codecs
import sys
from math import log
from collections import defaultdict
class Trie (object):
class TrieNode:
@davideuler
davideuler / README.md
Created December 5, 2015 14:50 — forked from hwdsl2/.MOVED.md
IPsec L2TP VPN Auto Install Script for Ubuntu 14.04 & 12.04 and Debian 8
@davideuler
davideuler / gitlab-rocketchat.hooks.js
Created October 17, 2016 08:26 — forked from malko/gitlab-rocketchat.hooks.js
Gitlab / Rocketchat intégration
/*jshint esnext:true*/
// see https://gitlab.com/help/web_hooks/web_hooks for full json posted by GitLab
const NOTIF_COLOR = '#6498CC';
const refParser = (ref) => ref.replace(/^.*?([^\/]+)$/,'$1');
class Script {
process_incoming_request({request}) {
try {
switch(request.headers['x-gitlab-event']){
case 'Push Hook':
@davideuler
davideuler / ffmpeg.md
Created February 27, 2018 12:24 — forked from protrolium/ffmpeg.md
using ffmpeg to extract audio from video files

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz:

@davideuler
davideuler / prometheus_metrics.py
Last active May 13, 2018 00:22
A simple Prometheus metrics server in python for statistics of website user count
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
import time
from pymongo import MongoClient
from prometheus_client import start_http_server
from prometheus_client.core import GaugeMetricFamily, CounterMetricFamily, REGISTRY
from config.settings import MONGO_USER, MONGO_PASS, MONGO_URL, MONGO_DBNAME
@davideuler
davideuler / publish_msg_to_nsq.py
Created May 13, 2018 14:05
Script to publish message to NSQ by python
import gnsq
conn = gnsq.Nsqd(address='localhost', http_port=4151)
conn.publish('topic_name', 'hello gevent!')
conn.publish('topic_name', 'hello nsq!')
@davideuler
davideuler / redis-mq.py
Created May 13, 2018 14:06
Publish and scribe redis message in python
from multiprocessing import Process
import time
import redis
# publish random message
def pub(myredis):
for n in range(10):
myredis.publish('channel_rand','blah %d' % n)
time.sleep(1)
@davideuler
davideuler / README.md
Created May 15, 2021 15:13 — forked from balupton/README.md
Convert XPS to PDF on Linux and Mac using bash

Convert XPS to PDF on Linux and Mac

  1. Download this file

  2. chmod +x ./xps2pdf.bash

  3. To convert a particular xps file: ./xps2pdf.bash thefile.xps

  4. To convert all xps files in the current working directory: ./xps2pdf.bash *.xps