Skip to content

Instantly share code, notes, and snippets.

View klepsydra's full-sized avatar

Marcos Koby klepsydra

  • US
View GitHub Profile
@danvbe
danvbe / 1-Explanations.md
Last active July 13, 2025 20:06
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.
@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'.
*
@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
*
@Integralist
Integralist / Hash Keys to Symbols.rb
Last active September 2, 2020 08:50
Convert Ruby Hash keys into symbols
hash = { 'foo' => 'bar' }
# Version 1
hash = Hash[hash.map { |k, v| [k.to_sym, v] }]
# Version 2
hash = hash.reduce({}) do |memo, (k, v)|
memo.tap { |m| m[k.to_sym] = v }
end
@Osse
Osse / gist:9553403
Created March 14, 2014 18:07
Cannot shutdown
$ sudo systemctl poweroff
Failed to start poweroff.target: Connection timed out
$ sudo shutdown -h now
Failed to start poweroff.target: Activation of org.freedesktop.systemd1 timed out
Failed to open /dev/initctl: No such device or address
Failed to talk to init daemon.
@thertrader
thertrader / ShinyForTradingStrategy.txt
Last active June 17, 2023 15:59
A Simple Shiny App for Monitoring Trading Strategies
This Shiny application is designed to help analysing trading strategies. It is an ongoing project that I improve when time allows. Feel free to get in touch should you have any suggestion.
*How to use the App as it is?
The App uses as input several csv files (one for each strategy). Each file has two columns: date and daily return. There is an example of such a file in the Github repository. The code is essentially made of 3 files.
-ui.R: controls the layout and appearance of the app
-server.R: contains the instructions needed to build the app. You can load as much strategies as you want as long as the corresponding csv file has the right format (see below).
-shinyStrategyGeneral.R: loads the required packages and launches the app
put ui.R and server.R file in a separate directory
In the server.R file change the inputPath, inputFile and keepColumns parameters to match your setting. The first two are self explanatory the third one is a list of column names within the csv file. Keep only date and daily return
@klepsydra
klepsydra / sync-fail2ban.sh
Last active June 11, 2025 17:44
Block globally reported hack attempts using your local iptables firewall rules
#!/bin/bash
## Update fail2ban iptables with globally known attackers.
## Actually, runs 100% independently now, without needing fail2ban installed.
##
## /etc/cron.daily/sync-fail2ban
##
## Author: Marcos Kobylecki <[email protected]>
## http://www.reddit.com/r/linux/comments/2nvzur/shared_blacklists_from_fail2ban/
@solyarisoftware
solyarisoftware / idle.rb
Last active July 11, 2023 20:58
Ruby script to test how to fetch IMAP mails (IDLE "push" mode) without pulling (in "real-time")
# Encoding: utf-8
#
# idle.rb
#
# goal:
# Ruby script to test how to fetch IMAP mails with IDLE mode.
# IMAP IDLE allow a sort of "push" / "real-time" delivery.
#
# I used the script to test LATENCY (end-to-end delivery times)
@emaraschio
emaraschio / SOLID.markdown
Last active February 16, 2025 23:43
SOLID Principles with ruby examples

SOLID Principles with ruby examples

SRP - Single responsibility principle

A class should have only a single responsibility.

Every class should have a single responsibility, and that responsibility should be entirely encapsulated. All its services should be narrowly aligned with that responsibility, this embrace the high cohesion.

OCP - Open/closed principle

Software entities should be open for extension, but closed for modification.

@franzalex
franzalex / TextArea_Backup_with_Expiry_Fix.user.js
Last active April 3, 2018 08:24
Creates a backup of input and textArea fields for restoration after data loss. It offers similar functionality as the Lazarus Firefox extension which is no longer supported.
// ==UserScript==
// @author Crend King
// @contributor Franz Alex Gaisie-Essilfie
// @version 2.4.20170620
// @name Textarea Backup with expiry Fix
// @namespace http://users.soe.ucsc.edu/~kjin
// @description Fix @grant https://greasyfork.org/zh-CN/forum/discussion/8161
// @description Retains text entered into textareas and contentEditables, and expires after certain time span.
// @include http://*
// @include https://*