Skip to content

Instantly share code, notes, and snippets.

View mayrund's full-sized avatar

May run mayrund

View GitHub Profile
chmod cheat sheet
PERMISSION COMMAND
U G W
_____________________________________
|rwx rwx rwx chmod 777 <filename> |
|_____________________________________|
|rwx rwx r-x chmod 775 <filename> |
|_____________________________________|
#!/bin/bash
if [ -e /usr/bin/python ]
then
echo "Python found!"
else
echo "Python missing!"
fi
@bmcculley
bmcculley / gist:ff66594523512bbbec06
Created October 6, 2014 03:01
Remove duplicate rows from table
DELETE FROM `table`
WHERE id IN (SELECT *
FROM (SELECT id FROM `table`
GROUP BY column HAVING (COUNT(*) > 1)
) AS A
);
@nicolaiarocci
nicolaiarocci / Microsoft .NET Framework 4.0 KB2468871 (x64).prq
Created September 8, 2014 08:22
.NET Framework 4.0 InstallShield KB2468871 Custom Prerequisites
<?xml version="1.0" encoding="UTF-8"?>
<SetupPrereq>
<conditions>
<condition Type="16" Comparison="2" Path="[WindowsFolder]Microsoft.NET\Framework\v4.0.30319" FileName="mscorlib.dll" ReturnValue="4.0.30319.233"></condition>
<condition Type="1" Comparison="2" Path="HKEY_LOCAL_MACHINE\SOFTWARE\wow6432node\Microsoft\Updates\Microsoft .NET Framework 4 Extended\KB2468871\" FileName="" ReturnValue=""></condition>
<condition Type="1" Comparison="2" Path="HKEY_LOCAL_MACHINE\SOFTWARE\wow6432node\Microsoft\Updates\Microsoft .NET Framework 4 Client Profile\KB2468871\" FileName="" ReturnValue=""></condition>
</conditions>
<operatingsystemconditions>
<operatingsystemcondition MajorVersion="5" MinorVersion="2" PlatformId="2" CSDVersion="" Bits="4" ProductType="1" ServicePackMajorMin="3"></operatingsystemcondition>
<operatingsystemcondition MajorVersion="5" MinorVersion="2" PlatformId="2" CSDVersion="" Bits="4" ProductType="2|3" ServicePackMajorMin="2"></operatingsystemcondition>
@ik5
ik5 / ard_red.ino
Last active August 29, 2015 14:04
arduino based red color alarm for israeli missiles alert - a PoC video: http://youtu.be/AdF2AGIjtvY
int led = 13;
int in = 0;
void setup() {
pinMode(led, OUTPUT);
Serial.begin(9600);
}
void loop() {
if (Serial.available() == 0) {
@bmcculley
bmcculley / search-and-replace.sh
Created March 25, 2014 04:26
Search and replace a word throughout a directory.
find ./ -type f -exec sed -i 's/apple/orange/g' {} \;
@bmcculley
bmcculley / compatible.php
Created March 1, 2014 04:57
Make sure the server PHP version is compatible with code.
<?php
if (version_compare(phpversion(), '5.3.10', '<')) {
// php version isn't high enough
echo 'version too low.';
}
else {
echo 'good to go.';
}
@keningle
keningle / gist:4582308
Created January 20, 2013 22:37
Check to see if function exists in PHP.
if (function_exists('function_name')) {
function_name()
}
@ik5
ik5 / gist:0e10b413c6d9ae4dc712
Created June 20, 2012 18:53
human readable sizes
def human_size(size, si = false)
return '0' if size == 0
base = si ? 1000 : 1024
bytes = %w(B KB MB GB TB PB EB ZB YB)
cnt = Math.log(size, base).floor
size = size / (base * 1.0) ** cnt
fmt = size < 10 ? '%.1f %s' : '%i %s'
sprintf(fmt, size, bytes[cnt])
@swallentin
swallentin / version.php
Created March 2, 2012 08:17
Find out what version of PHP a website is currently running in
<?php
echo 'Current PHP version: ' . phpversion();