Skip to content

Instantly share code, notes, and snippets.

View macedd's full-sized avatar
🐋
Looking for growth opportunities

Thiago F Macedo macedd

🐋
Looking for growth opportunities
View GitHub Profile
@macedd
macedd / force-autoplay.js
Created February 4, 2015 23:15
WP Video (mediaelementjs) force autoload
$(window).on('load', function() {
var player = $('video.wp-video-shortcode').data('mediaelementplayer');
player.options.success = function(media, dom) {
if (media.pluginType === 'flash') {
media.addEventListener('canplay', function() {
// Player is ready
media.play();
}, false);
} else {
media.play();
@macedd
macedd / Csv_Writer.php
Last active August 29, 2015 14:16
Large Dataset Csv Writer Class
<?php
class Csv_Writer
{
public $stream, $wrote = false;
function __construct() {
header( 'Content-Type: text/csv' );
$this->stream = fopen('php://output', 'w');
}
@macedd
macedd / Gruntfile.js
Created March 18, 2015 07:01
SSH Remote IPython Console Grunt Commands
/**
* IPython Commands
*/
shell: {
ipnb_kernel: {
command: 'ssh me@server "nohup ipython kernel &> kernel.log &"'
},
ipnb_kernel_json: {
command: 'rsync -t me@server:~/.ipython/profile_default/security/kernel* ./kernel/'
},
@macedd
macedd / gist:85d787e9a436ca19969d
Last active August 29, 2015 14:23
remove duplicate spaces from field while typing
$('textarea').on('keyup', function() {
// store cursor location
var start = this.selectionStart,
end = this.selectionEnd,
len = this.value.length;
// remove duplicate spaces from field
$(this).val(
this.value.trim()
.replace(/(\n\n)+/g, '\n')
@macedd
macedd / gist:1c201a9de84fb893d138
Created July 3, 2015 20:09
Responsive Triangle Less Mixin
/**
Based on the work:
- http://jsfiddle.net/josedvq/3HG6d/
- http://codeitdown.com/css-triangles-responsive/
*/
.responsive-triangle-base(@size; @color;) {
width: @size/2;
height: 0;
@macedd
macedd / gist:61fe1f806bf3cf030a22
Created July 5, 2015 01:16
Python Class: Google Image Search Api
import urllib2, urllib
import simplejson
opener = urllib2.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
class ImageApi(object):
uri = "http://ajax.googleapis.com/ajax/services/search/images?v=1.0&%s"
params = { 'q': 'term', 'imgsz': 'medium|large|xlarge', 'start': 0, 'imgtype': 'photo' }
@macedd
macedd / app.php
Created August 23, 2015 03:59
Lumen MongoDB Setup
$app->register('Jenssegers\Mongodb\MongodbServiceProvider');
$app->withEloquent();
$app->withFacades();
config(['database.connections.mongodb' => array(
'driver' => 'mongodb',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', 27017),
'username' => env('DB_USERNAME'),
@macedd
macedd / .htaccess
Last active October 19, 2015 12:25
WordPress installed subfolder served in root
# BEGIN WP Admin
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^wp-admin/(.*)$ /site/wp-admin/$1 [QSA,L]
RewriteRule ^wp-(.*)$ /site/wp-$1 [QSA,L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
@macedd
macedd / security-check.php
Created December 30, 2015 01:59
Simple Security checks for PHP
<?php
print_r([
exec('woami'), // shell access
get_current_user(), // running user
file_get_contents('/etc/hosts') // open_basedir restriction
]);
@macedd
macedd / webkit.css
Created January 3, 2016 21:44
Cordova Trigger GPU Rendering
.gpu {
-webkit-transform: translateZ(0);
}