Skip to content

Instantly share code, notes, and snippets.

View samsonasik's full-sized avatar
🔥
I am doing very fast fix 🚀, sponsor me 💖 https://github.com/sponsors/samsonasik

Abdul Malik Ikhsan samsonasik

🔥
I am doing very fast fix 🚀, sponsor me 💖 https://github.com/sponsors/samsonasik
View GitHub Profile
@padraic
padraic / escaping-rfc.md
Created July 7, 2012 14:27
Escaping RFC for PHP Core - Basically Zend\Escaper in C

* Version: 1.0

* Date: 2012-09-18

* Author: Pádraic <padraic.brady.at.gmail.com>

* Status: Under Discussion

* First Published at: http://wiki.php.net/rfc/escaper

@tawfekov
tawfekov / generator.php
Last active March 2, 2024 16:06
Doctrine2 Generate Entities form Existing Database
<?php
include '../vendor/autoload.php';
$classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__);
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Proxies', __DIR__);
$classLoader->register();
// config
$config = new \Doctrine\ORM\Configuration();
@Wneh
Wneh / ConsoleTable.java
Created November 24, 2012 10:37
Java class that prints a matrix/table to the console
/* The MIT License (MIT)
* Copyright (c) 2012 Carl Eriksson
*
* Permission is hereby granted, free of charge, to any person obtaininga
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction,including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software
* is furnished to do so, subject to the following conditions:
*
@Ocramius
Ocramius / .gitignore
Last active August 26, 2020 04:41
`in_array` vs `array_unique` performance example (just a test, not really interesting data)
tests
composer.lock
composer.phar
vendor
@matheusoliveira
matheusoliveira / json_manipulator.sql
Last active February 17, 2024 15:14
Simple PostgreSQL functions to manipulate json objects. (Note: performance is not a concern for those functions)
CREATE OR REPLACE FUNCTION public.json_append(data json, insert_data json)
RETURNS json
IMMUTABLE
LANGUAGE sql
AS $$
SELECT ('{'||string_agg(to_json(key)||':'||value, ',')||'}')::json
FROM (
SELECT * FROM json_each(data)
UNION ALL
SELECT * FROM json_each(insert_data)
@samsonasik
samsonasik / EntityManagerFactory.php
Created August 11, 2014 22:36
register doctrine extension in zf2 doctrine module
<?php
namespace Common\Service;
use Doctrine\ORM\EntityManager;
use DoctrineModule\Service\AbstractFactory;
use Zend\ServiceManager\ServiceLocatorInterface;
class EntityManagerFactory extends AbstractFactory
{
@BinaryMuse
BinaryMuse / overrides.js
Created September 20, 2014 08:14
setTimeout via Web Worker
var timeoutId = 0;
var timeouts = {};
var worker = new Worker("/static/timeout-worker.js");
worker.addEventListener("message", function(evt) {
var data = evt.data,
id = data.id,
fn = timeouts[id].fn,
args = timeouts[id].args;
<?php
namespace Mockizart\Bundle\BlogBundle\Controller;
use Mockizart\Bundle\BlogBundle\MockizartBlogBundle;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Mockizart\Bundle\BlogBundle\Entity\MockblogTag;
use Mockizart\Bundle\BlogBundle\Form\MockblogTagType;
@WebReflection
WebReflection / String.prototype.template.js
Last active August 17, 2022 04:04
ES6 Template like strings in ES3 compatible syntax.
// this is now a module:
// https://github.com/WebReflection/backtick-template#es2015-backticks-for-es3-engines--
var template = require('backtick-template');
// just string
const info = 'template';
`some ${info}` === template('some ${info}', {info});
@jonathanstark
jonathanstark / verify-google-recaptcha-with-php
Last active March 8, 2024 18:24
Verify Google reCAPTCHA with PHP
#
# Verify captcha
$post_data = http_build_query(
array(
'secret' => CAPTCHA_SECRET,
'response' => $_POST['g-recaptcha-response'],
'remoteip' => $_SERVER['REMOTE_ADDR']
)
);
$opts = array('http' =>