Skip to content

Instantly share code, notes, and snippets.

View rredpoppy's full-sized avatar

Adrian Rosian rredpoppy

View GitHub Profile
@Problematic
Problematic / RegistrationController.php
Created May 26, 2011 16:21
Symfony2 user registration mockup
<?php
namespace Problematic\UserBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Problematic\UserBundle\Entity\User;
class RegistrationController extends Controller
{
@ChubV
ChubV / FormType.php
Created November 29, 2012 07:56
Set form values after bind
class FormType extends AbstractType
{
// ....
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('field')
->add(....)
->addEventListener(FormEvents::POST_BIND, array($this, 'postBind'));
}
@wichert
wichert / form-example.html
Created November 30, 2012 09:55
WTForms and pyramid integration
<form id="loginForm" method="post" action="${request.route_url('login')}">
<input type="hidden" name="csrf_token" value="${request.session.get_csrf_token()}"/>
<fieldset class="concise">
<metal:field tal:define="name 'came_from'" use-macro="snippets['hidden']"/>
<metal:field tal:define="name 'login'" use-macro="snippets['text']"/>
<metal:field tal:define="name 'password'" use-macro="snippets['password']"/>
</fieldset>
<div class="buttonBar">
<button type="submit" class="default" i18n:translate="">Login</button>
</div>
@younes200
younes200 / install.sh
Last active January 21, 2018 07:52
UV4L + Webrtc
curl http://www.linux-projects.org/listing/uv4l_repo/lrkey.asc | sudo apt-key add -
sudo vi /etc/apt/sources.list
cat /etc/apt/sources.list
deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi
deb http://www.linux-projects.org/listing/uv4l_repo/raspbian/ wheezy main
sudo apt-get update
sudo apt-get install uv4l-webrtc
sudo apt-get install uv4l-raspicam-extras
sudo service uv4l_raspicam restart
(ns create-draw.opencv
(:import
org.opencv.core.Core
org.opencv.core.Mat
org.opencv.core.MatOfRect
org.opencv.core.Point
org.opencv.core.Rect
org.opencv.core.Scalar
org.opencv.highgui.Highgui
org.opencv.objdetect.CascadeClassifier))
@pitluga
pitluga / core.clj
Created October 29, 2012 18:58
Braintree Clojure Example
(ns braintree-clj.core
(:import [com.braintreegateway BraintreeGateway Environment TransactionRequest Transaction$Type])
(:require [clojure.string :as s]
[hiccup.core :as hiccup]
[hiccup.page-helpers :as page-helper]
[noir.core :as noir]
[noir.request :as noir-req]
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE UndecidableInstances #-}
module Fix where
-- Definitions:
--
-- If (μF,inF) is the initial F-algebra for some endofunctor F
@rmrfself
rmrfself / transaction.php
Created May 19, 2012 07:27
How to make transactions in Doctrine 2 using Symfony 2
<?php
// Snippet for Symfony 2 application that uses Doctrine 2 to handle transactions
// It uses the names of the objects/doctrine repositories from the Beta 4 Manual of Symfony 2.
// Get the entity manager
$em = $this->getDoctrine()->getEntityManager();
// suspend auto-commit
$em->getConnection()->beginTransaction();
@samuelantonioli
samuelantonioli / setup.sh
Last active July 4, 2021 23:24
wire-server setup using fake dependencies
#!/bin/bash
# chmod +x setup.sh && ./setup.sh
# [!] only for testing! this is not stable or secure
# it takes some hours.
# it is available under http://<server-ip>:8080
#
# make sure that you run ubuntu 16.04
# you need minimum 25gb (10gb filled with build dependencies)
@tfausak
tfausak / wss.hs
Last active August 10, 2021 18:25
Secure WebSockets in Haskell.
-- base ==4.7.0.1
-- bytestring ==0.10.4.0
-- connection ==0.2.4
-- network ==2.4.2.3
-- text ==1.1.0.0
-- websockets ==0.9.3.1
import Control.Concurrent (forkIO)
import Control.Monad (forever, void)
import qualified Data.ByteString as BS