Skip to content

Instantly share code, notes, and snippets.

<?php
$filter_r=216;
$filter_g=0;
$filter_b=26;
$suffixe="_red";
$path=YOURPATHFILE;
if(is_file($path)){
$image=@imagecreatefromjpeg($path);
$new_path=substr($path,0,strlen($path)-4).$suffixe.".png";
@Sigmus
Sigmus / beautiful.js
Created December 17, 2014 02:25
A Beautiful Function
var handleCheckAlternative = function(result) {
var playSound = playWrongAudio;
var after = renderInfos;
if (isLastQuestion(result)) {
after = _.compose(renderPoints, quizOver);
}
if (result.correct && isLastQuestion(result)) {
playSound = playTouchdown;
}
else if (result.correct) {
<?php
class Destaque extends Aware {
const STATUS_PUBLISHED = 1;
const STATUS_UNPUBLISHED = 0;
public static $rules = array(
@Sigmus
Sigmus / heredoc.php
Last active August 29, 2015 14:05
heredoc.php
<?php
$trocar = 'tentar';
$conteudo = <<<DEMO
Isto é um teste. Vamos $trocar dados.
DEMO;
<?php
class Krudder {
public static function add($route, $modelName)
{
App::bind("Krudder$route", function() use($route, $modelName)
{
return new KrudderController($route, $modelName);
});
<?php
class Scorer {
private $canonical;
private $game;
public function __construct($game)
{
@Sigmus
Sigmus / collection+json.json
Created July 23, 2014 03:20
Collection+JSON document
{
"collection": {
"version": "1.0",
"href": "http://www.youtypeitwepostit.com/api/",
"items": [
{
"href": "/api/messages/21818525390699506",
"data": [
{
"name": "text",
@Sigmus
Sigmus / replace-parent.js
Created July 21, 2014 21:36
A small module that replaces it's parent element content with the provided html.
var _ = require('lodash');
module.exports = _.curry(replaceParent, 2);
function replaceParent(element, html) {
var parent = element.parentNode;
parent.innerHTML = html;
@Sigmus
Sigmus / example.js
Created July 12, 2014 16:10
A React Google Maps Component
var GmapComponent = require('./google-maps-component');
var component = GmapComponent({
lat: -23.5348644, lng: -46.6718231
});
var node = document.getElementById('main');
React.renderComponent(component, node);
@Sigmus
Sigmus / youtube_extract.php
Created July 11, 2014 13:41
PHP Regex to get youtube video ID
<?php
/*
* From: http://stackoverflow.com/questions/3392993/php-regex-to-get-youtube-video-id
*/
$url = "http://www.youtube.com/watch?v=C4kxS1ksqtw&feature=relate";
parse_str( parse_url( $url, PHP_URL_QUERY ), $my_array_of_vars );
echo $my_array_of_vars['v'];
// Output: C4kxS1ksqtw