Skip to content

Instantly share code, notes, and snippets.

@DarkPark
DarkPark / mk.java.sh
Created November 24, 2013 14:20
How to install oracle JRE on Ubuntu.
#!/bin/bash
# step 1
# download tar.gz from oracle site http://www.oracle.com/technetwork/java/javase/downloads/index.html
# for example jre-7u45-linux-i586.tar.gz
# step 2
# prepare build tools
sudo apt-get install java-package
@DarkPark
DarkPark / tips.linux.sh
Last active December 31, 2015 21:28
set of useful commands
# turn off the given monitor
xrandr --output LVDS --off
# enable/disable composting
xfconf-query --channel=xfwm4 --property=/general/use_compositing --type=bool --toggle
# exit the script if try to use an uninitialized variable
set -u
# exit the script if any statement returns a non-true return value
@DarkPark
DarkPark / tips.mysql.sh
Created December 20, 2013 16:04
mysql db management
# set pass in command line (non-interactive)
mysqladmin -u root password "some_new_password"
# set pass in command line (interactive)
mysqladmin -u root password
# login
mysql -u[name] -p[pass] [database]
# create backup
@DarkPark
DarkPark / csvfile.py
Created January 6, 2014 18:43
Fix for Anki to increase cards size limit on import
# /usr/share/anki/anki/importing/csvfile.py
import sys
csv.field_size_limit(sys.maxsize)
@DarkPark
DarkPark / dart.sh
Created July 21, 2014 20:35
install dart on ubuntu
sudo add-apt-repository ppa:hachre/dart
sudo apt-get update
sudo apt-get install darteditor dartvm dartsdk dartium
@DarkPark
DarkPark / table.map.js
Last active August 29, 2015 14:12
Table navigation map generator with tests.
'use strict';
var data = {
'table 1x1 with no merge': {
raw: [
[1]
],
check: [[1]]
},
@DarkPark
DarkPark / SassMeister-input.scss
Created February 17, 2016 14:11
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
%component {
// The width and height (also including min-width, max-width, min-height and max-height properties) of an element
// are calculated as the width/height of the content plus the padding and border.
box-sizing: border-box;
}
@DarkPark
DarkPark / benchmark.js
Created October 16, 2016 11:04
manual conversion vs TextEncoder
var tries = 100000,
encoder = new TextEncoder('utf-8'),
example = 'I♥☢𝄢. I\'m a ☢ ☃ that plays 𝄢 guitar and spea̧͈͖ks Ar̽̾̈́͒͑ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜!',
time, index;
function utf8ToBinaryString ( str ) {
var escstr = encodeURIComponent(str);
// replaces any uri escape sequence, such as %0A,
// with binary escape, such as 0x0A
var binstr = escstr.replace(/%([0-9A-F]{2})/g, function ( match, p1 ) {
@DarkPark
DarkPark / move.sh
Last active April 8, 2017 20:44
How to move the /root directory to home partition
# it'b better to avoid symlinks
# use mount --bind
# as root
cp -a /root /home/
echo "" >> /etc/fstab
echo "/home/root /root none defaults,bind 0 0" >> /etc/fstab
# do it now
cd / ; mv /root /root.old; mkdir /root; chmod go-rwx /root; mount -a
mkfifo dptmp
while true; do
read line < dptmp
if [[ $line ]]; then
echo "processing $line"
fi
done