Skip to content

Instantly share code, notes, and snippets.

View atdt's full-sized avatar
💭
I may be slow to respond.

Ori Livneh atdt

💭
I may be slow to respond.
  • Google
  • New York City
View GitHub Profile
import urllib.request
import re
import bs4
def soup_url(url):
req = urllib.request.Request(url)
with urllib.request.urlopen(req) as resp:
return bs4.BeautifulSoup(resp.read(), 'html.parser')
<?php
class Node implements JsonSerializable {
public function __construct( $name, $contents ) {
$this->name = $name;
$this->store = [];
foreach ( (array)$contents as $k => $v ) {
if ( is_int( $k ) ) {
$this->addChild( $v );
} else {
$this->addAttribute( $k, $v );
var assert = require( 'assert' );
function findFrequentBigram( s ) {
var i, freqs = {}, topFreq = 0, topPair = null, bigram;
for ( i = 0; i < s.length; i += 2 ) {
bigram = s.slice( i, i + 2 );
freq = ++freqs[bigram];
@atdt
atdt / longurl.js
Last active January 12, 2020 00:36
// Generate a long URL (>5000 characters), request it twice, and check that:
// - the query param at the end of the URL was honored
// - the second resp was served from the cache
var https = require( 'https' ),
count = 0,
url = 'https://en.wikipedia.org/w/load.php?q=';
while ( url.length < 5000 ) {
url += Math.random().toString( 36 ).substring( 7 );
#!/usr/bin/env/python3
"""
Get most commonly used Graphite functions in Grafana dashboards
Requires Python 3
"""
import collections
import json
import re
import sqlite3
--- a/cs1.lua
+++ b/cs1.lua
@@ -25,7 +25,7 @@ delare variables here that have page-wide scope
]]
-local Preview_mode = false; -- flag indicating that we are rendering a preview page (Show preview button)
+local is_preview_result = nil; -- flag indicating that we are rendering a preview page (Show preview button)
--[[--------------------------< F I R S T _ S E T >------------------------------------------------------------
@atdt
atdt / alerts-leaderboard.py
Last active May 2, 2018 13:29
Leaderboard of icinga-wm alerts
# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import collections
import datetime
import operator
import itertools
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import contextlib
import json
import os
import re
import shutil
import subprocess
import sys
import urllib2
<?php
function globalInclude( $__phpFile ) {
$__retVal = include_once $__phpFile;
foreach ( get_defined_vars() as $name => &$value ) {
if ( $name !== '__phpFile' && $name !== '__retVal' ) {
$GLOBALS[ $name ] =& $value;
}
}
return $__retVal;
}
@atdt
atdt / mc1008
Created May 6, 2016 08:32
slab stats on mc1008 and mc1009
chunk_size used_chunks total_chunks mem_requested mem_wasted
88 0 11915 0 1048520
96 8 10922 768 1047744
104 2138 10082 218987 829541
112 15348 18724 1700751 396337
120 282277 288354 32666317 1936163
128 13940 16384 1736633 360519
136 9233 15420 1232754 864366
144 17025 21843 2374793 770599
152 18746 20694 2798468 347020