Skip to content

Instantly share code, notes, and snippets.

@CoolOppo
CoolOppo / Background Command in Ubuntu.md
Last active August 29, 2015 14:00
Run a command in the background in Ubuntu

Use (setsid yourcommand &), it detaches from the tty and works equally in interactive and script modes.

( spawns a subshell, which handles job control differently.

Or use nohup yourcommand > /dev/null 2>&1 &

Tags

  • Linux
@CoolOppo
CoolOppo / Paste in Console.md
Last active August 29, 2015 14:00
Game pause script

Want to paste it straight into the console?

bind v noclip;sv_allow_wait_command 1;sv_cheats 1;mp_warmuptime 5;mp_warmuptime_all_players_connected 0;mp_warmup_end;mp_afterroundmoney 256000;mp_autokick 0;mp_autoteambalance 0;mp_buy_anywhere 1;mp_buytime 999999;mp_free_armor 1;mp_freezetime 0;mp_friendlyfire 0;mp_limitteams 30;mp_maxmoney 256000;mp_respawn_on_death_ct 1;mp_respawn_on_death_t 1;mp_respawnwavetime_ct 1;mp_respawnwavetime_t 1;mp_roundtime 60;mp_roundtime_defuse 60;mp_roundtime_hostage 60;mp_startmoney 256000;sv_infinite_ammo 1;mp_humanteam CT;bot_join_team T;bot_quota 3;bot_quota_mode normal;bot_stop 1;mp_restartgame 1
@CoolOppo
CoolOppo / WriteToMemory.cpp
Created April 28, 2014 08:41
Writes data to a specified location in memory
void WriteToMemory(int address_writing_to, char* value_to_write, int num_of_bytes)
{
unsigned long old_protection; // Create a place to store our old protection
VirtualProtect((LPVOID)address_writing_to, num_of_bytes, PAGE_EXECUTE_READWRITE, &old_protection); // Give me proper access to the memory (and store the old protection in the variable 'old_protection').
memcpy((LPVOID)address_writing_to, value_to_write, old_protection); // Write our value.
VirtualProtect((LPVOID)address_writing_to, num_of_bytes, old_protection, NULL); // Restore the protection back to that of 'old_protection'.
}
@CoolOppo
CoolOppo / Random Image From Direct URL.php
Last active August 29, 2015 14:01
Displays a random GIF image at an unchanging direct URL/URI using PHP
<?php
function random_pic($dir = '/var/www/images') {
$files = glob($dir . '/*.gif');
if (!$files) return false;
$file = array_rand($files);
return $files[$file];
}
function outputImage( $filename ) {
@CoolOppo
CoolOppo / PageSpeed Filters.md
Created June 5, 2014 16:53
List of extra PageSpeed Module filters that are not enabled by the "CoreFilters" directive
  • canonicalize_javascript_libraries
  • collapse_whitespace
  • combine_heads
  • convert_jpeg_to_webp
  • convert_to_webp_lossless
  • dedup_inlined_images
  • elide_attributes
  • extend_cache_pdfs
  • inline_google_font_css
  • inline_preview_images

Windows system key combinations

  • ALT+F4: Quit program
  • ALT+TAB: Switch between open programs
  • CTRL+ESC: Open Start menu
  • F1: Help
  • SHIFT+DELETE: Delete item permanently
  • SHIFT+Windows Logo+M: Undo minimize all
  • Windows Logo+D: Minimizes all open windows and displays the desktop
  • Windows Logo+E: Windows Explorer
  • Windows Logo+F: Find files or folders

launch4j exec error

I was having a shit ton of problems getting launch4j to work. Simply get a recent version of MinGW's ld.exe and windres.exe files, and replace the ones in the bin folder. That seems to do the trick.

Another thing to try is using the DOS path instead of the standard Windows one when you refer to the directory containing JRE. Apparently, the tool doesn't support paths with spaces in them, although it is somewhat sporadic. I used cygpath to generate my path. The command I used is cygpath -wsa "C:\Program Files (x86)\Java\jre1.8.0_20", which resulted in C:\PROGRA~2\Java\JRE18~1.0_2 as the DOS path.

A working XML config for launch4j is below.

<?xml version="1.0" encoding="UTF-8" ?>
@CoolOppo
CoolOppo / jdk-make-portable.bat
Last active August 29, 2015 14:05
Converts an extracted JDK directory to actually make it run portably
for /r %%x in (*.pack) do bin\unpack200 "%%~x" "%%~dpnx.jar" && del /q /f "%%~x"
@CoolOppo
CoolOppo / update-ffmpeg.sh
Created May 21, 2015 20:30
Automatically delete the contents of /c/ffmpeg, fetch the latest shared 64-bit build of ffmpeg from Zeranoe, extract it, put it in a tar file whilst deleting the directory contents after the pieces are put into the TAR, then extract the TAR, using --strip-components=2 in order to extract the files directly into /c/ffmpeg rather than /c/ffmpeg/ro…
#!/usr/bin/env bash
cd /c/ffmpeg
rm -rf ./*
aria2c --file-allocation=falloc http://ffmpeg.zeranoe.com/builds/win64/shared/ffmpeg-latest-win64-shared.7z
7z x ffmpeg-latest-win64-shared.7z
rm ffmpeg-latest-win64-shared.7z
tar -c --remove-files -f ffmpeg.tar ./*
tar -x --strip-components=2 -f ffmpeg.tar
rm ffmpeg.tar