Skip to content

Instantly share code, notes, and snippets.

@freayd
freayd / install.sh
Created November 18, 2018 09:16
Install ClamAV on macOS
#!/bin/bash
CONFIG_FOLDER=/usr/local/etc/clamav
CLAMD_CONFIG_FILE=$CONFIG_FOLDER/clamd.conf
FRESHCLAM_CONFIG_FILE=$CONFIG_FOLDER/freshclam.conf
DB_FOLDER=/usr/local/var/lib/clamav
RUN_FOLDER=/usr/local/var/run/clamav
LOG_FOLDER=/usr/local/var/log
CLAMD_LOG_FILE=$LOG_FOLDER/clamd.log
CLAMD_ERROR_LOG_FILE=$LOG_FOLDER/clamd.error.log
@freayd
freayd / stats.js
Created April 5, 2017 17:53
Rough Java packages usage on Github
// Run this script in a Javascript console while browsing Github.
// Do not abuse, thanks!
var pkgs = ["java.applet","java.awt","java.beans","java.io","java.lang","java.math","java.net","java.nio","java.rmi","java.security","java.sql","java.text","java.time","java.util","javax.accessibility","javax.activation","javax.activity","javax.annotation","javax.crypto","javax.imageio","javax.jws","javax.lang","javax.management","javax.naming","javax.net","javax.print","javax.rmi","javax.script","javax.security","javax.sound","javax.sql","javax.swing","javax.tools","javax.transaction","javax.xml","org.ietf","org.omg","org.w3c","org.xml"];
var counts = {};
function requestByPackageIndex(i) {
var pkg = pkgs[i];
var xhr = new XMLHttpRequest();
xhr.open("GET", "/search?q=import+" + pkg + "&type=Code&utf8=%E2%9C%93&_pjax=%23js-pjax-container", true);
@freayd
freayd / copyright
Created March 5, 2017 10:12
Debian SID openjdk-8-doc_8u121-b13-4_all.deb
@freayd
freayd / gist:1128f091143080f4b0fa
Created December 26, 2015 06:04
[Overpass API] Incorrect ele tags in China
[out:json][timeout:25];
area[name="中国"][admin_level=2][boundary=administrative]->.china;
(
node(area.china)["ele"~"[^0-9\.,]"];
way(area.china)["ele"~"[^0-9\.,]"];
relation(area.china)["ele"~"[^0-9\.,]"];
);
out body;
// >;
// out skel qt;
@freayd
freayd / .bashrc
Last active August 29, 2015 14:10
Bash / VIM private mode
function upsearch () {
dir="${PWD}"
while true
do
[[ -f "${dir}/${1}" ]] && return 0
[[ "${dir}" == '/' ]] && return 1
dir=$(dirname "${dir}")
done
}
function update_window_title() {
@freayd
freayd / readme.md
Created May 12, 2013 17:26
Prevent brightness (both for screen and keyboard backlight) to be reset to maximum on every restart (Ubuntu on a MacBook only)

Install

  1. Copy the script to the file /usr/local/bin/save-and-restore-brightness.sh
  2. Run the following command: sudo chmod a+x /usr/local/bin/save-and-restore-brightness.sh
  3. Append the following line to the file /etc/pam.d/lightdm: session optional pam_exec.so /usr/local/bin/save-and-restore-brightness.sh

Note

This script can be adapted to any laptop by adjusting the variables SCREEN_BRIGHTNESS_FILE and KEYBOARD_BRIGHTNESS_FILE.

@freayd
freayd / readme.md
Last active December 17, 2015 01:59
Run commands when a volume is mounted (OS X only)

How to

Create the files here:

  • ~/Library/LaunchAgents/on-volume-mounted.plist
  • ~/Library/Scripts/on-volume-mounted.rb
  • ~/Library/Scripts/on-volume-mounted.yml

Update paths in file 'on-volume-mounted.plist'.

@freayd
freayd / latin_map.pl
Created March 27, 2013 18:52
Converting text to basic latin (aka removing accents) with JavaScript
#!/usr/bin/perl -w
use strict;
use warnings;
use charnames ':full';
use encoding "UTF-8";
use vars qw($ch);
my @names = <DATA>;
chomp for @names;
@freayd
freayd / readme.md
Last active October 12, 2017 05:48
NextGEN Gallery image source for Wysija Newsletters WordPress plugin

This feature is really important for me, that's why I developed it. I share this bunch of code in the hope that it will be useful, but without any warranty.

How to

Add the code between "Add this code - begin" and "Add this code - end" in the corresponding files.

Tested with

  • WordPress 3.5.1