Skip to content

Instantly share code, notes, and snippets.

View klepsydra's full-sized avatar

Marcos Koby klepsydra

  • US
View GitHub Profile
@maxgalbu
maxgalbu / Switch_Node.php
Last active December 31, 2019 16:03
Switch tag for Twig, updated from https://github.com/fabpot/Twig/pull/185 to work with Twig >= 1.12
<?php
//To be added under Twig/Node/Switch.php
/*
* This file is part of Twig.
*
* (c) 2009 Fabien Potencier
* (c) 2009 Armin Ronacher
*
@Diftraku
Diftraku / gist:5888214
Created June 28, 2013 21:18
A "simple" PHP function to convert arrays into DataTable JSON export format fit to use with Google Charts
<?php
/**
* arrayToDataTable()
* Converts PHP arrays to nested arrays fit for json_encode()
*
* Format Notice:
* - $cols contains all the columns for the DataTable, each column having a type and a label.
* Columns can be defined as plain arrays (containing only type and label, see below) or as a named array,
* with each of the properties defined as key => value pairs. All columns must have at least a 'type'.
*
@danvbe
danvbe / 1-Explanations.md
Last active April 21, 2023 15:39
A way to integrate FosUserBundle and HWIOAuthBundle

I have managed to install this… and make it work. I implemented it for Facebook and Google, but you can extend it. My solution it is mostly as described in #116, with a bit of more code presented. The key aspects that lack in the #116 presentation (IMO) are:

  • the registration as service of your custom FOSUBUserProvider (with the necessary parameters)
  • set the service for oauth_user_provider in the security.yml with your custom created service

Here are the steps:

  1. Routing. In routing.yml I have added all the routes for both bundles.
  2. Configuration. I have set the config.yml mostly as it is presented in the HWIOAuthBundle.
  3. Security. I have set the security.yml mostly as it is presented in the HWIOAuthBundle (though my routes are using /login pattern, not /connect). Also, the oauth_user_provider is set for my custom service.
anonymous
anonymous / gist:4169393
Created November 29, 2012 14:19
Patched ruby psych to handle multiline regexp
module Psych
module Visitors
class ToRuby < Psych::Visitors::Visitor
def deserialize o
if klass = Psych.load_tags[o.tag]
instance = klass.allocate
if instance.respond_to?(:init_with)
coder = Psych::Coder.new(o.tag)
coder.scalar = o.value
@johntyree
johntyree / getBlockLists.sh
Last active March 9, 2024 12:32
Make one large blocklist from the bluetack lists on iblocklist.com
#!/usr/bin/env sh
# Download lists, unpack and filter, write to stdout
curl -s https://www.iblocklist.com/lists.php \
| sed -n "s/.*value='\(http:.*=bt_.*\)'.*/\1/p" \
| xargs wget -O - \
| gunzip \
| egrep -v '^#'
@subelsky
subelsky / casperjs_example.js
Created August 8, 2012 18:51
Webscraping with CasperJS, PhantomJS, jQuery, and XPath
var system = require('system');
if (system.args.length < 5) {
console.info("You need to pass in account name, username, password, and path to casperJS as arguments to this code.");
phantom.exit();
}
var account = system.args[1];
var username = system.args[2];
var password = system.args[3];
@klepsydra
klepsydra / ST.50209607.statsTable.txt
Created April 2, 2012 19:45
ST.50209607.statsTable.txt
+----------------+---------------+---------------+---------------+
| Performance of Scottrade_50209607, 2012-04-02T00:24:33+02:00 |
+----------------+---------------+---------------+---------------+
|group |Unrealized |Realized |Combined |
+----------------+---------------+---------------+---------------+
| openValueSum | 2347.31 | 3056.22 | 1865.23 |
| closeValueSum | 2365.24 | 3132.37 | 1883.16 |
| gainLossRaw | 17.93 | 76.15 | 94.08 |
| profitSum | 17.93 | 76.15 | 94.08 |
| gainLossPerc | 0.76 | 2.49 | 5.04 |
@klepsydra
klepsydra / gist:2286570
Created April 2, 2012 19:29
triglist.GPW.txt
BUY WARFAMA 20120327 1.52 18.57923 2595257 lastprice=1.67 targetprice=1.35 quantity>=569.80
BUY TRAKCJA 20120323 1.21 18.40000 7787679 lastprice=1.16 targetprice=.94 quantity>=818.32
BUY DSS 20120322 4.62 18.39286 1250754 lastprice=3.70 targetprice=3.01 quantity>=255.55
BUY ABMSOLID 20120330 3.20 18.36735 3341862 lastprice=3.14 targetprice=2.56 quantity>=300.48
BUY BIOTON 20120329 0.10 18.18182 1713404 lastprice=0.09 targetprice=.07 quantity>=10989.00
BUY CIECH 20120320 16.45 12.26667 6342807 lastprice=16.65 targetprice=14.60 quantity>=52.68
BUY SKOTAN 20120319 3.03 11.38462 5863662 lastprice=3.57 targetprice=3.16 quantity>=243.42
BUY OVOSTAR 20120328 111.90 10 1003295 lastprice=109.20 targetprice=98.28 quantity>=7.82
BUY MIDAS 20120321 0.90 8.33333 11032438 last
@andris9
andris9 / git-cache-meta.sh
Created March 5, 2012 13:15
git-cache-meta
#!/bin/sh -e
#git-cache-meta -- simple file meta data caching and applying.
#Simpler than etckeeper, metastore, setgitperms, etc.
#from http://www.kerneltrap.org/mailarchive/git/2009/1/9/4654694
#modified by n1k
# - save all files metadata not only from other users
# - save numeric uid and gid
# 2012-03-05 - added filetime, andris9
@murphyslaw
murphyslaw / CSV Duplication Remover
Created May 28, 2011 07:49
A ruby script that removes duplicate rows in a csv file. Duplicates are found based on an identifier column and a criteria column, which are configurable.
#!/usr/bin/ruby -w
require 'csv'
require 'active_support/core_ext'
class Parser
attr_accessor :input_folder
attr_accessor :output_folder
attr_accessor :filename