Skip to content

Instantly share code, notes, and snippets.

@zetas
zetas / admin.py
Created August 9, 2013 00:57
One class to build them all...
class TransactionAdmin(admin.ModelAdmin):
fields = ['date', 'bitcoin_address', 'payment_method', 'amount', 'email_address', 'completed']
list_display = ['id', 'date', 'bitcoin_address', 'payment_method', 'amount', 'email_address', 'completed']
readonly_fields = ['id', 'date']
search_fields = ['^email_address', '^id', '^payment_method']
list_filter = ['payment_method', 'completed']
list_display_links = ['date']
inlines = [TransactionDetailAdmin]
actions = ['really_delete_selected']
@zetas
zetas / DefaultController.php
Created August 23, 2013 00:39
Symfony & Doctrine Fun
$repository = $this->getDoctrine()
->getRepository('MainUserBundle:Feedback')
;
$query = $repository->createQueryBuilder('f')
->where('f.trade = :trade')
->andWhere('f.user = :user OR f.fromUser = :fromuser')
->setParameter('trade', $trade)
->setParameter('user', $this->getUser())
->setParameter('fromuser', $this->getUser())
->getQuery()
@zetas
zetas / DefaultController.php
Created August 26, 2013 17:58
I love symfony2
/**
* @Route("/", name="trade_index")
* @Route("/direct", name="trade_index_direct")
* @Route("/escrow", name="trade_index_escrow")
* @Template()
*/
public function indexAction($_route)
{
$sortArray = array(
'completedByUser' => null,
@zetas
zetas / EscrowController.php
Created August 26, 2013 18:45
I must be a professional to have all these includes!
namespace Main\TradeBundle\Controller;
use JMS\DiExtraBundle\Annotation as DI;
use JMS\Payment\CoreBundle\Entity\Payment;
use JMS\Payment\CoreBundle\PluginController\Result;
use JMS\Payment\CoreBundle\Plugin\Exception\ActionRequiredException;
use JMS\Payment\CoreBundle\Plugin\Exception\Action\VisitUrl;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
@zetas
zetas / ApiController.php
Created August 27, 2013 16:33
Super complex bitcoin api callback!
/**
* @Route("/bitcoin/{token}", name="api_bitcoin_callback")
* @Template
*/
public function bitcoinCallbackAction($token, Request $request) {
$bitcoinSVC = $this->get('main_user.bitcoinservice');
if (!$uid = $bitcoinSVC->validateCallback($token,$request->get('destination_address')))
return false;
@zetas
zetas / gist:7603965
Created November 22, 2013 17:43
Lol, i've gone a little crazy methinks.
bundle exec rspec
[Report a Problem]0 min 9 sec
ActiveRecord::SchemaMigration Load (0.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
TodosController
POST create
with valid params
 (2.2ms) BEGIN
Processing by TodosController#create as HTML
Parameters: {"todo"=>{"title"=>"MyString"}}
@zetas
zetas / gist:8084948
Created December 22, 2013 16:27
first mixin
@mixin background_image($url, $px) {
background: url($url) no-repeat scroll $px 50% transparent;
}
@zetas
zetas / application.coffee
Created December 29, 2013 05:21
CoffeeScript file for my text analytics. It works pretty damn well. Analyzing a paper with 1000 words takes about 100ms.
fluffPhraseList = ['actually', 'in-all-actuality', 'how about that', 'however then', 'however because of that', 'and also', 'and/or', 'as to whether', 'basically', 'essentially', 'technically', 'totally', 'for sure', 'being that ', 'being as', 'on account of that', 'on account of ', 'on account of this', 'point in time', 'that time', 'this time', 'quite', 'really', 'so as to', 'sort of', 'try and', 'very', 'well then', 'even then', 'so then', 'really then', 'although then', 'however then', 'also then', 'then also', 'as then', 'if then', 'therefore then', 'overall then', 'and though', 'and because of this', 'and because of that', 'and furthermore', 'and however', 'and this is because', 'and overall', 'and now', 'because ', 'because of this', 'because of that', 'because this is', 'this is because', 'because that is', 'because i am', 'because you are', 'furthermore because of that', 'because furthermore', 'overall because of that', 'because overall', 'because now', 'because that', 'that is because', 'because how
@zetas
zetas / app.coffee
Created January 23, 2014 08:56
My first javascript app (in coffeescript ofcourse lol)
fluffPhraseList = ['actually', 'in-all-actuality', 'how about that', 'however then', 'however because of that', 'and also', 'and/or', 'as to whether', 'basically', 'essentially', 'technically', 'totally', 'for sure', 'being that ', 'being as', 'on account of that', 'on account of ', 'on account of this', 'point in time', 'that time', 'this time', 'quite', 'really', 'so as to', 'sort of', 'try and', 'very', 'well then', 'even then', 'so then', 'really then', 'although then', 'however then', 'also then', 'then also', 'as then', 'if then', 'therefore then', 'overall then', 'and though', 'and because of this', 'and because of that', 'and furthermore', 'and however', 'and this is because', 'and overall', 'and now', 'because ', 'because of this', 'because of that', 'because this is', 'this is because', 'because that is', 'because i am', 'because you are', 'furthermore because of that', 'because furthermore', 'overall because of that', 'because overall', 'because now', 'because that', 'that is because', 'because how
@zetas
zetas / gist:8707088
Created January 30, 2014 12:01
Secure UUID Generation in PHP. Change 16 to get a larger or smaller uuid.
$bytes = openssl_random_pseudo_bytes(16);
$uuid = bin2hex($bytes);