Skip to content

Instantly share code, notes, and snippets.

View dryliketoast's full-sized avatar

Michael Kane dryliketoast

View GitHub Profile
@dryliketoast
dryliketoast / html5-data-attr
Last active December 18, 2016 21:54
html5 howto: pass args from markup to jquery using "data-" attribute
HTML5:
<a class="clicker" data-mynumber="311">Click</a>
JQUERY:
$('.clicker').attr('data-mynumber');
// returns 311
$('.clicker').data('mynumber');
// returns 311
@dryliketoast
dryliketoast / regex-url
Created November 10, 2011 15:45
regex for URL matching
From rfc3986:
As the "first-match-wins" algorithm is identical to the "greedy"
disambiguation method used by POSIX regular expressions, it is
natural and commonplace to use a regular expression for parsing the
potential five components of a URI reference.
The following line is the regular expression for breaking-down a
well-formed URI reference into its components.
@dryliketoast
dryliketoast / gist:98ed9dc4522374ce8491
Created July 22, 2014 07:56
iptables time based rules
iptables -t mangle -A timedredirection -m time --timestart 06:00:00 --timestop 21:00:00 -j RETURN
@dryliketoast
dryliketoast / gist:7ca004ec77d4e3cd6a21
Last active September 11, 2015 16:26
line returns in bash
With bash, if you want to embed newlines in a string, enclose the string with $'':
$ list="One\ntwo\nthree\nfour"
$ echo "$list"
One\ntwo\nthree\nfour
$ list=$'One\ntwo\nthree\nfour'
$ echo "$list"
One
two
three
Base 36 to Integer:
intval($str,36)
Integer to Base 36:
base_convert($val, 10, 36)
So then, instead of redirecting to a route like /url/1234 it becomes /url/ax instead.
This gives you a whole lot more use than a hash will, as there will be no collisions.
Don't hash, use other bases for this kind of thing. (It's faster and can be made collision-proof.)
# convert pdf to high resolution image
convert -density 1200 page.pdf -resample 300 page.jpg
Keybindings
C-a tab - switch input focus to the next region.
C-a Q - remove all regions but the current one.
C-a S - split the current region horizontally into two new regions.
C-a X - remove the current region.
C-a | - split the current region vertically into two new regions.
Focusing Regions
The focus command is relatively simplistic. Even though regions may be laid out in a two-dimensional space, screen maintains them internally as a simple list, and focus simply moves forwards or backwards through the list. (There are also focus subcommands to jump to the beginning of the list–the upper-leftmost region–and to the end of the list–the lower rightmost region.) The order is pretty intuitive, and it's easier to tell you to try it out than to try to describe it.
Written by Thanos Apostolou
http://askubuntu.com/questions/53822/how-do-you-run-ubuntu-server-with-a-gui
Some more info can be found here https://help.ubuntu.com/community/ServerGUI. I assume you start with a clean install of Ubuntu Server 16.04 (some modifications may be needed for older versions of Ubuntu). Depending on your needs you can do these:
Minimal GUI:
sudo apt install xorg
sudo apt install --no-install-recommends openbox
Run the command startx and openbox will start (you can open a terminal there and run any application you want)
PS C:\WINDOWS\system32> Set-ExecutionPolicy RemoteSigned
PS C:\WINDOWS\system32> $UserCredential = Get-Credential
PS C:\WINDOWS\system32> $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
PS C:\WINDOWS\system32> Import-PSSession $Session
PS C:\WINDOWS\system32> New-DistributionGroup -PrimarySmtpAddress {distro_email_address} -Name "{my distro group}" -Members {list_of_recipients_email_addresses,comma,separated}
#!/bin/bash
#
# src: https://www.iplocation.net/traffic-control
#
# tc uses the following units when passed as a parameter.
# kbps: Kilobytes per second
# mbps: Megabytes per second
# kbit: Kilobits per second
# mbit: Megabits per second
# bps: Bytes per second