That's Geeky

Engage your cerebral cortex

Login

Main menu

Skip to primary content
Skip to secondary content
  • Home
  • About
  • CLI #Ref
  • Privacy Policy

Category Archives: Code Snippets

Random bits of useful code I come across – most likely not of my own creation.

Post navigation

← Older posts

Capturing Termination Signals in PHP

Posted on November 18, 2011 by cyberx86
Reply

Consider the scenario of a PHP script which can be run for a period of time, stopped, and continue its task later on. A common necessity for such a script may be to detect when the script is terminated, and … Continue reading →

Posted in: Code Snippets Tagged: php, signals

Missing mail command on Amazon’s Linux

Posted on October 7, 2011 by cyberx86
Reply

I recently noticed that the mail command is not available by default on the latest version of Amazon’s Linux AMI (v2011.09). This functionality is available in the mailx package, which can be installed with the following: yum install mailx

Posted in: Code Snippets Tagged: aws, mail

Showing the Firebug icon

Posted on October 2, 2011 by cyberx86
Reply

While it is easy enough to use F12 to display Firebug in Firefox, I just like the status bar icon. Unfortunately, it has been hidden in the last few releases of Firebug. To display it, open about:config, and set extensions.firebug.showStatusIcon … Continue reading →

Posted in: Code Snippets Tagged: firebug

Optimize all MySQL Tables

Posted on August 9, 2011 by cyberx86
Reply

A one-liner to optimize all MySQL tables, in all databases. Be advised that running optimize on InnoDB does a ‘recreate and analyze’. Run as root in the example below. mysqlcheck -o -u root -p –all-databases

Posted in: Code Snippets Tagged: mysql, optimize

Updating the Flash Plugin

Posted on August 9, 2011 by cyberx86
2

Adobe’s Flash plugin (v10.3) is setup to check for updates on restart. However, at least recently, on my setup, there have been a couple of little annoyances. Either it launches and tries to check for updates before my wifi connects … Continue reading →

Posted in: Code Snippets Tagged: command prompt, flash

Verify that SSL caching is working

Posted on July 24, 2011 by cyberx86
Reply

To verify that SSL caching is on, check the Session-ID across multiple sessions (i.e. resume/reconnect) – they should be the same: openssl s_client -host HOSTNAME -port 443 -reconnect | grep ‘Session-ID:’ The equivalent, using gnutls-cli should be: gnutls-cli -V -r … Continue reading →

Posted in: Code Snippets Tagged: ssl, tls

Rebuild Icon Cache

Posted on May 24, 2011 by cyberx86
2

Recently, after upgrading a program (FileZilla in this case), the program’s icon would not display on the desktop (Windows 7). Even deleting and recreating the shortcut resulted in a broken icon (although, the shortcut itself worked fine). No amount of … Continue reading →

Posted in: Code Snippets Tagged: command prompt, icons, windows

Prime Factoring with PHP

Posted on March 28, 2011 by cyberx86
4

A surprisingly large number of math based computer problems appear to require factorization, finding prime number, or prime factoring. Presented below is a reasonably fast algorithm for prime factoring a number – it is limited to the integer size on … Continue reading →

Posted in: Code Snippets Tagged: factors, math, php

Apache: Not GET Request

Posted on December 3, 2010 by cyberx86
Reply

My error logs were recently filled with repetions of the the following line: [Date] [warn] [client IP] Not GET request: 2., referer: As it turned out this was caused by the mod_pagespeed module (from Google). Disabling it has stopped the … Continue reading →

Posted in: Code Snippets

Decoding a Base64 Email Attachment

Posted on November 20, 2010 by cyberx86
Reply

I had a few files containing email attachments that needed to be converted into usable files. The following code (which has no checks in it), did the trick: <?php function decode_email_attachment(){ $data= file_get_contents($inputfile); file_put_contents($outputfile, base64_decode(str_replace( “\r\n”, “”, $data ))); } … Continue reading →

Posted in: Code Snippets Tagged: base64, email

Fractions

Posted on November 11, 2010 by cyberx86
Reply

For many people the mere mention of fractions elicits a wince, and while these lovely math constructs played a notable role in our early years of math, they are reasonably simple entities. While most humans revisit fractions over many years … Continue reading →

Posted in: Code Snippets, Random Tagged: fractions, math, php

Bundle Error on AWS

Posted on October 24, 2010 by cyberx86
Reply

On servers running certain forms of chroot, a file system loop is created (in /var/named/chroot), causing errors when attempting to bundle the volume. This occurs in particular when running BIND (named). To successfully bundle the volume, simply stop named: sudo … Continue reading →

Posted in: Code Snippets Tagged: aws, named

Setting the timezone on PHP

Posted on October 23, 2010 by cyberx86
Reply

Versions of PHP after 5.10 include the date.timezone directive in php.ini. Many applications which reference time need this directive to be set. A list of accepted values can be found at: http://www.php.net/manual/en/timezones.php The timezone is set as a quoted string, … Continue reading →

Posted in: Code Snippets Tagged: php, time

Time on AWS Linux AMI

Posted on October 6, 2010 by cyberx86
3

The time on the Amazon Linux AMI is set, by default to UTC. To change this, symlink one of the timezone files from /usr/share/zoneinfo/ to /etc/localtime. The change takes effect immediately (and will also affect most logs, etc). For example: … Continue reading →

Posted in: Code Snippets Tagged: aws, linux, time

Post navigation

← Older posts
January 2021
M T W T F S S
« Aug    
 123
45678910
11121314151617
18192021222324
25262728293031

Popular Posts

  • Installing ApacheBench without Apache on Amazon’s Linux
  • Connect to Amazon’s Linux via WinSCP as root
  • Physical Activity Ratios
  • Directly connecting to PHP-FPM
  • Basic Diagnostics for Hibernate and Sleep
  • Easy Windows-Linux File Sharing with a LiveCD
  • FileZilla’s Quickconnect List
  • Using Telnet with an SMTP Server
  • Windowless VirtualBox VMs (Windows Host)
  • Autoscaling with custom metrics

Tags

apache audio aws backup cache cdn cloudfront command prompt cron diagnostics dkim dns domainkeys EC2 Elastic Block Store email fastcgi filezilla flash ftp hard drive httpd ide linux math named nginx nodejs php postfix rsyslog s3 sata security ssh ssl suhosin time tls varnish virtualbox virtualmin vsftpd windows wordpress

Categories

  • Computers
    • Audio
    • Hardware
    • Internet
    • Multiboot
    • Software
      • Code Snippets
    • Systems Admin
      • Cluster
    • Video
  • Electronics
  • Random
    • Philosophy
  • Science
    • Biology
    • Chemistry
    • Stories

Content copyright © 2021 · That's Geeky

Privacy Policy