Skip to content

Instantly share code, notes, and snippets.

@MrAlexWeber
MrAlexWeber / gist:1598943
Created January 12, 2012 05:27
AutoHotKey Macro: WIN+N to minimize window and move it to the back
;Add this to your AutoHotKey.ahk!
#n::
WID := WinExist("A") ;get the ID for the active window
WinSet, Bottom,, ahk_id %WID% ;move it to bottom of stack (like ALT+ESC)
WinMinimize, ahk_id %WID% ;and minimize it
Return
@MrAlexWeber
MrAlexWeber / gist:1609456
Created January 14, 2012 00:00
filezilla quick upload modified file and switch to chrome
+F5::
SetTitleMatchMode, 2
IfWinNotExist, File has changed
{
IfWinExist, - FileZilla
{
WinActivate
Sleep 500
}
}
@MrAlexWeber
MrAlexWeber / makedev for use after imaging EC2 fs to EBS
Created March 16, 2012 22:28
after running rsync to back up an EC2 instance, run this makedev command to create devices and make it bootable
MAKEDEV std generic sd ram pty tty console
@MrAlexWeber
MrAlexWeber / remove posts from category.sql
Created May 4, 2012 01:46
sql to remove posts from a category given a post author and category id
delete b
from wp_posts a
left join wp_term_relationships b ON ( a.ID = b.object_id )
LEFT JOIN wp_term_taxonomy d ON ( d.term_taxonomy_id = b.term_taxonomy_id )
LEFT JOIN wp_terms e ON ( e.term_id = d.term_id )
WHERE e.term_id = YOUR_TERM_ID and a.post_author = YOUR_AUTHOR_ID;
@MrAlexWeber
MrAlexWeber / lame-make-mp3-mono.sh
Created September 18, 2012 00:05
make an MP3 mono @ 48kbps with LAME
lame --mp3input -a -b 48 --resample 44.1 infile.mp3 [outfile.mp3]
<?php
/* This bit is in use on my site still, originally coded in 2012.
You can see an example on this page: http://alexweber.is/nerdy/
*/
/** custom page+category logic **/
function list_posts_if_also_category() {
if(is_page() && !is_home() && !is_front_page()){
$this_post_title = the_title('','',FALSE);
@MrAlexWeber
MrAlexWeber / charisma-score-calculation.php
Created November 13, 2013 22:35
Code Samples part 2…
<?php
/* This was used on a marketing quiz based on a formula provided by a marketer.
It was my job to make his rough logic into something that worked!
*/
/* description:
** pull variables from $_POST: conf, char, aggr, rapp, kiss, date
** quiz_points = scale(20=0, 100=50)(conf + char + aggr + rapp)
**
** kiss_points = kiss * 2.5 (maximum of 25)
@MrAlexWeber
MrAlexWeber / dev-or-prod-widget.php
Created November 13, 2013 22:37
Simple WordPress widget to check if you're in a development environment.
<?php
/* dev_or_prod_widget by mr.alexweber@gmail.com
** checks our IP against the DNS record for our hostname
** if they don't match, this is probably a development server
*/
function dev_or_prod_widget() {
$my_ip = trim( file_get_contents('http://icanhazip.com') );
$my_domain = $_SERVER['SERVER_NAME'];
$official_ip = gethostbyname($my_domain);
function wrap_html_attr($atts, $content = null){
/* input e.g. 'value="[some_shortcode]"' */
return do_shortcode( $content );
}
add_shortcode( 'wha', 'wrap_html_attr' );
@MrAlexWeber
MrAlexWeber / install-moon-macos.sh
Created July 13, 2020 17:12
How to run wttr.in/Moon (pyphoon) locally
#!/bin/sh
# This is what I did, YMMV
# See also: https://github.com/chubin/pyphoon/issues/27
cd ~
git clone https://github.com/chubin/pyphoon
cd pyphoon
pip install -r requirements.txt
chmod +x setup.py
./setup.py develop