Skip to content

Instantly share code, notes, and snippets.

@josuecau
josuecau / gist:8c0d842d513586d971e2
Last active August 29, 2015 14:11 — forked from Huluk/gist:5117702
Terminal Vim as default editor application in Mac OS X
If you want your terminal vim to open files you double click, follow the following steps (MacOS only):
1. Open Automator
2. Select Application
3. Select "Run AppleScript" action and copy the attached script
4. Save and set as default for opening files
Multiple files are opened in vim tabs.
If there is already a vim instance running, files are opened in it.
<?php
function excerpt($text, $length = 100, $after = '&hellip;')
{
if (mb_strlen($text) > $length) {
$text = preg_replace('/\s+?(\S+)?$/', '', mb_substr($text, 0, $length + 1)) . $after;
}
return $text;
}
@josuecau
josuecau / openname-verification.txt
Last active August 29, 2015 14:14
OpenName verification
Verifying that +josuecau is my openname (Bitcoin username)
https://onename.com/josuecau
@josuecau
josuecau / ipblacklist.sh
Last active August 29, 2015 14:14
Top 10 of blocked IP by Fail2ban
#!/bin/sh
awk '($(NF-1) = /Ban/){print $NF}' /var/log/fail2ban.log | sort | uniq -c | sort -r -n -k 1,1 | head -n 10
{
"exclude": [
".git/**",
"node_modules/**",
"bower_components/**"
],
"always-semicolon": true,
"block-indent": " ",
"color-case": "lower",
"color-shorthand": true,
--recurse
--tag-relative=yes
--PHP-kinds=+cf-v
--exclude=.svn
--exclude=.git
--exclude=*.js
--regex-PHP=/abstract\s+class\s+([^ ]+)/\1/c/
--regex-PHP=/interface\s+([^ ]+)/\1/c/
<?php
/**
* Transfert des fichiers modifiés depuis un commit vers un hôte distant.
* Synopsis : php deploy.php commit [user@]host:dir
* Exemple : php deploy.php C0MM1TH45H^ host.example.com:/path/to/dir
*/
// Pas en CLI
if (PHP_SAPI !== 'cli') {
@josuecau
josuecau / groupby.html
Created September 25, 2015 08:53
Split list into groups
<ol>
<li>A</li>
<li>B</li>
<li>C</li>
</ol>
<ol>
<li>D</li>
<li>E</li>
<li>F</li>
</ol>
@josuecau
josuecau / .htaccess
Created November 4, 2011 07:16
Simple PHP routing
RewriteEngine On
#RewriteBase /path/to/dir/
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# add trailing slash
RewriteRule ^.*[^/]$ $0/ [L,R=301]
RewriteRule ^.*$ index.php [NC,L]
@josuecau
josuecau / .gitignore
Created December 14, 2011 09:17 — forked from redoPop/.gitignore
Template .gitignore file for WordPress projects
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your