Skip to content

Instantly share code, notes, and snippets.

View Hubbitus's full-sized avatar

Pavel Alexeev aka Pahan-Hubbitus Hubbitus

View GitHub Profile
@twasink
twasink / build.gradle
Last active May 17, 2016 22:26
A skeleton for a gradle file to augment ExtJS's Sencha Cmd-generated build scripts. This particular one assumes the application is in a workspace.
ant.importBuild 'build.xml'
def packages_dir = file('../packages')
clean {
doLast { delete 'bootstrap.js', 'bootstrap.css', 'bootstrap.json' }
}
refresh {
inputs.dir 'app'
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<style>
#piechart {
top: 0;
left: 0;
width:100%;
height:100%;
@zed
zed / time33.py
Last active April 15, 2019 09:04
time.process_time() and time.perf_counter() for Python 2 on Ubuntu.
"""time.process_time() and time.perf_counter() for Python 2 on Ubuntu."""
import ctypes
import errno
from ctypes.util import find_library
from functools import partial
CLOCK_PROCESS_CPUTIME_ID = 2 # time.h
CLOCK_MONOTONIC_RAW = 4
clockid_t = ctypes.c_int
@ohneda
ohneda / StandardDeviationCategory.groovy
Created July 21, 2011 23:07
StandardDeviation Category for groovy, inspired by Advanced Rails
import static java.lang.Math.*
import static java.math.RoundingMode.CEILING
class StandardDeviationCategory {
static Double mean(Collection list) {
list.with{
scale(sum() / size())
}
}
@wolph
wolph / to_json.sql
Created April 6, 2012 10:35
Some functions to convert arrays/hstore to json :)
CREATE OR REPLACE FUNCTION escape_json (text) RETURNS text AS $$
SELECT replace($1, '''', '\'''); $$ LANGUAGE SQL IMMUTABLE;
CREATE OR REPLACE FUNCTION to_json(text) RETURNS text AS $$
SELECT escape_json($1) $$ LANGUAGE SQL IMMUTABLE;
CREATE OR REPLACE FUNCTION to_json(KEY text, value text) RETURNS text AS $$
SELECT '''' || to_json($1) || ''': ''' || to_json($2) || ''''; $$ LANGUAGE SQL IMMUTABLE;
@sdpatil
sdpatil / Producer.java
Created December 26, 2016 03:46
Kafak Sample producer that sends Json messages
package com.mapr.kafka.serializer.json;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.connect.json.JsonSerializer;
import java.util.Properties;
@fikovnik
fikovnik / build.gradle
Created May 8, 2016 19:58
Building maven plugins by gradle
configurations {
mavenEmbedder
}
dependencies {
compile "org.apache.maven:maven-core:$mavenVersion"
compile "org.apache.maven:maven-plugin-api:$mavenVersion"
compile 'org.apache.maven.plugin-tools:maven-plugin-annotations:3.4'
mavenEmbedder "org.apache.maven:maven-embedder:$mavenVersion"
@Hubbitus
Hubbitus / mount.afuse
Created February 11, 2017 15:00
Afuse sshfs automounter (/usr/sbin/mount.afuse)
#!/bin/bash
# afuse-sshfs mount helper to automatically mount remote machines.
# It is intended to be used as mount.afuse in command line. F.e. in /etc/fstab you may mount directory like:
# afuse# /mnt/remote afuse auto 0 0
# And then as regular user just do:
# $ cd /mnt/remote/user@remote.host/remote/path
# and folder /mnt/remote/user@remote.host will be mounted automatically!
#
# On Mac some also recommend add defer_permissions,noappledouble mount options.
@usmansaleem
usmansaleem / sample_multiline.yml
Created September 4, 2017 23:03
multiline docker environment variable (via docker compose)
environment:
SERVER_NAME: "myserver.doma.in"
# Dummy key, cert
SSL_KEY: |-
-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQD272jYrLm8Ph5QpMWFcWUO9Ua1EviykalP+tkMIg12yZ3GvezF
y8aayxdztB5vu68jqMeg6mOJlscWqFUhmAxj4mDknYenVzVX2CKzCgHlGninTKxY
61rXDaDZVpSZ+XIESJkaB0z9HHYtrSLr0coKmq4cT5TRptOnkpDlJxIRaQIDAQAB
AoGATcTYoGTFmiN2KK+8BWrRCQT2X9C5woNdb3LxKIEQ/HhC2HS4PRMQWW/c0vPH
IilZ30EoneUztAFochpRtWLNg4lJoLy04X/eNjEiC/imp0KSwWXmnuLhDcWcb0+M
@hgmnz
hgmnz / query_planner.markdown
Created March 23, 2011 14:14
PostgreSQL query plan and SQL performance notes

Types of index scans

Indexes

Sequential Scan:

  • Read every row in the table
  • No reading of index. Reading from indexes is also expensive.