Skip to content

Instantly share code, notes, and snippets.

View thebouv's full-sized avatar
🐍
Automating and/or breaking things

Anthony Bouvier thebouv

🐍
Automating and/or breaking things
View GitHub Profile
@thebouv
thebouv / gist:8742647
Created January 31, 2014 20:37
Return list of column names as a commas separated list
SELECT GROUP_CONCAT( COLUMN_NAME )
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'my_table';
@thebouv
thebouv / proxy.php
Created February 18, 2014 18:38
PHP POST proxy
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $REMOTEURLHERE);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($_POST));
$data = curl_exec($ch);
curl_close($ch);
@thebouv
thebouv / getRandom.php
Created February 19, 2014 16:19
PHP random string generation (for file names, etc)
function getRandom($length = 10) {
return substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);
}
@thebouv
thebouv / .bashrc
Created May 30, 2014 20:20
Colorful .bashrc for my OS X machines
export PS1="\[\e[00;36m\]\u\[\e[0m\]\[\e[00;37m\]@\h:\[\e[0m\]\[\e[00;33m\][\W]\[\e[0m\]\[\e[00;36m\]:\[\e[0m\]\[\e[00;37m\] \[\e[0m\]"
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GFh'
@thebouv
thebouv / nogutter.css
Created June 25, 2014 13:25
.no-gutter class for Bootstrap 3
.row.no-gutter {
margin-left: 0;
margin-right: 0;
}
.row.no-gutter [class*='col-']:not(:first-child),
.row.no-gutter [class*='col-']:not(:last-child) {
padding-right: 0;
padding-left: 0;
}
@thebouv
thebouv / attribute.txt
Created June 25, 2014 17:53
CSS attribute selector syntax
[att] Represents an element with the att attribute, whatever the value of the attribute.
[att=val] Represents an element with the att attribute whose value is exactly "val".
[att~=val] Represents an element with the att attribute whose value is a whitespace-separated list of words, one of which is exactly "val". If "val" contains whitespace, it will never represent anything (since the words are separated by spaces). Also if "val" is the empty string, it will never represent anything.
[att^=val] Represents an element with the att attribute whose value begins with the prefix "val". If "val" is the empty string then the selector does not represent anything.
[att$=val] Represents an element with the att attribute whose value ends with the suffix "val". If "val" is the empty string then the selector does not represent anything.
@thebouv
thebouv / web.config
Created July 1, 2014 20:13
IP restrict on Azure
<security>
<ipSecurity allowUnlisted="false" denyAction="NotFound">
<add allowed="true" ipAddress="1.2.3.4"/>
</ipSecurity>
</security>
or
http://azure.microsoft.com/blog/2013/12/09/ip-and-domain-restrictions-for-windows-azure-web-sites/
@thebouv
thebouv / preventDefault.js
Created July 29, 2014 20:17
preventDefault fix
(e.preventDefault) ? e.preventDefault() : event.returnValue = false;
@thebouv
thebouv / parse.js
Last active August 29, 2015 14:13
Parsing XML with namespace (such as slash:comments)
el[0].getElementsByTagNameNS('http://purl.org/rss/1.0/modules/slash/', 'comments')[0].innerHTML;
// or a fuller example
$.get('/blogfeed.php', function (data) {
var count = 1;
$(data).find("item").each(function () {
var el = $(this);
// ...
// how many comments
@thebouv
thebouv / fail2ban-cmds.sh
Created January 25, 2015 18:39
fail2ban-client
fail2ban-client status
fail2ban-client set ssh-iptables unbanip x.x.x.x