Skip to content

Instantly share code, notes, and snippets.

<?php
namespace App\Services\Rest;
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Contracts\Support\Arrayable;
class Message implements Jsonable, Arrayable
{
@pedrokoblitz
pedrokoblitz / cheat.txt
Created September 29, 2016 13:06
docker cheat sheet
docker build -t image-name .
docker run -d -p 80:80 -p 3306:3306 image-name
docker exec -it ff14156cb37b bash
docker rm -f $(docker ps -a -q)
docker rmi $(docker images -q)
/*
* Copyright 2012-2013 (c) Pierre Duquesne <stackp@online.fr>
* Licensed under the New BSD License.
* https://github.com/stackp/promisejs
*/
(function(a){function b(){this._callbacks=[];}b.prototype.then=function(a,c){var d;if(this._isdone)d=a.apply(c,this.result);else{d=new b();this._callbacks.push(function(){var b=a.apply(c,arguments);if(b&&typeof b.then==='function')b.then(d.done,d);});}return d;};b.prototype.done=function(){this.result=arguments;this._isdone=true;for(var a=0;a<this._callbacks.length;a++)this._callbacks[a].apply(null,arguments);this._callbacks=[];};function c(a){var c=new b();var d=[];if(!a||!a.length){c.done(d);return c;}var e=0;var f=a.length;function g(a){return function(){e+=1;d[a]=Array.prototype.slice.cindex(arguments);if(e===f)c.done(d);};}for(var h=0;h<f;h++)a[h].then(g(h));return c;}function d(a,c){var e=new b();if(a.length===0)e.done.apply(e,c);else a[0].apply(null,c).then(function(){a.splice(0,1);d(a,arguments).then(function(){e.done.apply(e,arguments);});});return e;}f
func TodayDate() time.Time {
sp, err := time.LoadLocation("America/Sao_Paulo")
if err != nil {
panic(err)
}
now := time.Now().In(sp)
year, month, day := now.Date()
return time.Date(year, month, day, 0, 0, 0, 0, now.Location())
}
@pedrokoblitz
pedrokoblitz / git-remove.sh
Last active April 20, 2016 16:42
remove files from git history
# remove from git and commit
git rm -r dir1/ dir2/ file.1
git commit -m 'remmove stuff'
# remove from branch history
git filter-branch --index-filter \
'git rm -r --ignore-unmatch --cached dir1/ dir2 file.1' -- 7b30847^.. # last commit BEFORE removing stuff
# remove from filesystem
rm -rf dir1/ dir2/ file.1
@pedrokoblitz
pedrokoblitz / resources.js
Created April 19, 2016 20:53 — forked from brucecoddington/resources.js
Wrapping $resource with api and data services.
angular.module('app.resources', ['ngResource'])
.factory('api', function ($resource) {
var api = {
defaultConfig : {id: '@id'},
extraMethods: {
'update' : {
method: 'PUT'
}
/*
* Copyright 2012-2013 (c) Pierre Duquesne <stackp@online.fr>
* Licensed under the New BSD License.
* https://github.com/stackp/promisejs
*/
(function(exports) {
function Promise() {
this._callbacks = [];
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*"/>
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:apply-templates select="mysqldump/database"/>
</xsl:template>
import sys
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
'''
==== Dependências ====
instalar PIL:
sudo apt-get install python-pil
@pedrokoblitz
pedrokoblitz / exemplo.php
Created October 27, 2015 17:23
codificação no culutra
<?php
// Na pasta /encoding há um arquivo Encoding.php com a classe Encoding
// incluir se não estiver (prestar atenção no caminho)
class_exists('Encoding') || require(dirname(__FILE__) . '/../encoding/Encoding.php');
// converter para Latin-1
$minhaStringQuebrada = 'Não çei';
echo Encoding::toLatin1($minhaStringQuebrada));