Skip to content

Instantly share code, notes, and snippets.

View kosinix's full-sized avatar

Kosinix kosinix

  • Philippines
View GitHub Profile
@kosinix
kosinix / rm-wp-revisions.sql
Created February 8, 2015 05:57
Delete WP Post revisions
DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'revision'
@kosinix
kosinix / mklink
Created January 26, 2015 01:00
Symbolic links in windows 7
@kosinix
kosinix / gist:f9c451eb6f9ccf34fc35
Last active August 29, 2015 14:09
Construct URL using symfony httpfoundation request
$request->getScheme().'://'.$request->getHttpHost().$request->getBasePath().$request->getPathInfo();
@kosinix
kosinix / gist:5ec1732db6068ec08854
Created October 30, 2014 11:12
Force shutdown windows in 60 seconds
shutdown -s -f -t 60
@kosinix
kosinix / request-component-query.txt
Last active November 3, 2015 04:02
get ?term=22 silex
$request->query->get('term');
@kosinix
kosinix / resumable-download.php
Created September 22, 2014 08:46
PHP - resumable download
<?php
class ResumeDownload {
private $file;
private $name;
private $boundary;
private $delay = 0;
private $size = 0;
function __construct($file, $delay = 0) {
if (! is_file($file)) {
@kosinix
kosinix / get_properties.php
Created September 17, 2014 01:37
Get all class properties at once and put it in an array
<?php
class Foo {
protected $var1;
protected $var2;
/* Get Properties
*
* Get all class properties at once and put it in an array
*
* @return array $class_vars
@kosinix
kosinix / generateRandomString.php
Last active August 29, 2015 14:06
Generate Password 12 characters long with some characters removed (l,1,0,o) for readability
<?php
function generateRandomString($length = 12) {
$characters = '23456789abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ !@#$%^&*()_-';
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, strlen($characters) - 1)];
}
return $randomString;
}
@kosinix
kosinix / gist:993b09fbb3389e44391b
Created September 4, 2014 05:49
C# - Delete a folder in a zip using dotnetzip. Docs: http://dotnetzip.herobo.com/DNZHelp/Index.html
using (ZipFile zip = ZipFile.Read(@"D:\path\to\ZipFile.zip"))
{
zip.RemoveSelectedEntries("foldername/*"); // Remove folder and all its contents
zip.Save();
}
@kosinix
kosinix / gist:7d8f19352782ff598e1f
Created August 20, 2014 00:04
Disable Post Revision and Delay Autosave in WP
wp-config.php:
define('AUTOSAVE_INTERVAL', 300 ); // seconds
define('WP_POST_REVISIONS', false );
SQL:
DELETE FROM wp_posts WHERE post_type = "revision";