Skip to content

Instantly share code, notes, and snippets.

View nicopenaredondo's full-sized avatar

Nico R. Penaredondo nicopenaredondo

View GitHub Profile
@nicopenaredondo
nicopenaredondo / ajax.php
Created January 22, 2014 08:23
simple ajax snippet
Route::post('ajax',function(){
if(Request::ajax())
{
$input = array(
'password' => Input::get('password')
);
$rules = array(
'password' => 'required'
);
<?php
class BlogController extends Controller
{
/**
* Posts
*
* @return void
*/
public function showPosts()
body::before {
content:"";
position:fixed;
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABLAAAAOEAgMAAADMAyBpAAAAA3NCSVQICAjb4U/gAAAACVBMVEX///9mmcxmmcw+elmfAAAAA3RSTlMAd/+3CsRiAAAACXBIWXMAAAsSAAALEgHS3X78AAAAFnRFWHRDcmVhdGlvbiBUaW1lADA5LzAyLzExT1Br7wAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNXG14zYAAAs2SURBVHic7duxrV1FGEZR44CAEoiIqcL1uAqXQAkEBOAqcXZe4OBMNHtJ3wRLVzIXbY3+uW+S+fTp0x+fPo+XBBIcAgkOgQSHQIJDIMEhkOAQSHAIJDB833q9Nlk7htusAIEEh0CCQyDBIZDgEEhwCCQw3L4VS2uTtWO4zQoQSHAIJDgEEhwCCQ6BBIdAAsPtW7G0Nlk7htusAIEEh0CCQyDBIZDgEEhwCCQw3L4VS2uTtWO4zQoQSHAIJDgEEhwCCQ7Px1/++/Avv//14b/5+uX5h1//ob7x9cvzDz/+o5//r15+4+Nmff7+4V/+/PtD1vdvzz/89i/1je/fnn/48R/9/H/18hu7wR+sTdbJZO036/039tfwiECCQyDBIZDgEEhwCCQ4BBIYbt+KpbXJ2jHcZgUIJDgEEhwCCQ6BBIdAgkMggeH2rVham6wdw21WgECCQyDBIZDgEEhwCCQ4BBIYbt+KpbXJ2jHcZgUIJDgEEhwCCQ6BBIdAgkMggeH2rVham6wdw21WgECCQyDBIZDgEEhweD4Cb7w6r8KA14N7ycqsTdbJZO036/039tfwiECCQyDBIZDgEEhwCCQ4BBIYbt+KpbXJ2jHcZgUIJDgEEhwCCQ6BBIdAgkMggeH2rVham6wdw21WgECCQyDBIZDgEEhwCCQ4BBIYbt+KpbXJ2jHcZgUIJ
<Vendor Name>
- Modules
- Blog
- Repository
--Doctrine(if doctrine is the orm)
--BlogRepository.php
--Entities
- Blog.php
--Proxies
--Eloquent(If eloquent is the orm)
<?php
namespace App\Helpers\Elasticsearch;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\Paginator;
class ElasticCollection extends Collection {
protected $response;
<?php
function codeGenerator($length)
{
$az = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZMULTIPAY';
$azr = rand(0, 51);
$azs = substr($az, $azr, 10);
$stamp = hash('sha256', time());
$mt = hash('sha256', mt_rand(5, 20));
$alpha = hash('sha256', $azs);
@nicopenaredondo
nicopenaredondo / serve.sh
Created May 11, 2016 02:16
NGINX Subdomain generator
#!/usr/bin/env bash
if [ -z $1 ]
then
echo "serve www.domain.com /path"
exit 1
fi
if [ -z $2 ]
then
@nicopenaredondo
nicopenaredondo / node_crypto.js
Created July 16, 2016 14:01 — forked from rojan/node_crypto.js
Encrypt in nodejs and decrypt in php or vice versa
var crypto = require('crypto');
var key = 'MySecretKey12345';
var iv = '1234567890123456';
var cipher = crypto.createCipheriv('aes-128-cbc', key, iv);
var decipher = crypto.createDecipheriv('aes-128-cbc', key, iv);
var text = 'plain text';
var encrypted = cipher.update(text, 'utf8', 'binary');
encrypted += cipher.final('binary');
hexVal = new Buffer(encrypted, 'binary');
_processInstructionItems(employerId, programs)
{
return new Promise((resolve, reject) => {
let self = this;
let listOfPrograms = [];
_.forEach(programs, item => {
Program.find(item.id).then(programData => {
this._processProgramItemCode(employerId, item, programData).then(programItem => {
listOfPrograms.push(programItem)
})
private function csvToArray($filename='', $delimiter=',')
{
$rows = array_map('str_getcsv', file($filename));
$header = array_shift($rows);
$csv = array();
foreach ($rows as $row) {
if(count($row) != count($header)) {
dd($row);
}