Skip to content

Instantly share code, notes, and snippets.

View istvanp's full-sized avatar
👨‍💻
Turning coffee into code

Istvan Pusztai istvanp

👨‍💻
Turning coffee into code
View GitHub Profile
@istvanp
istvanp / bootstrap_form.rb
Last active October 4, 2023 08:56
Bootstrap v5 bootstrap_form Floating Labels support
# config/initializers/bootstrap_form.rb
module BootstrapForm
module FormGroup
def form_group_classes(options)
classes = ['mb-3', options[:class].try(:split)].flatten.compact
classes << 'form-label-group' if options[:layout] == :floating
classes << 'row' if horizontal_group_with_gutters?(options[:layout], classes)
classes << 'col-auto g-3' if field_inline_override?(options[:layout])
classes << feedback_class if options[:icon]
classes
// create the audio context (chrome only for now)
var context = new webkitAudioContext();
var audioBuffer;
var sourceNode;
var analyser;
var javascriptNode;
// get the context from the canvas to draw on
var ctx = $("#canvas").get()[0].getContext("2d");
@istvanp
istvanp / gist:3148669
Created July 20, 2012 04:21
iptables
#!/bin/bash
#
# Flush iptables
#
iptables -F
#
# Allow SSH, HTTP, HTTPS
#
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
@istvanp
istvanp / nginx.rb
Created December 7, 2011 08:47
Modified Homebrew formula for nginx. Adds support for nginx_tcp_proxy_module (https://github.com/yaoweibin/nginx_tcp_proxy_module)
require 'formula'
class Nginx < Formula
homepage 'http://nginx.org/'
url 'http://nginx.org/download/nginx-1.0.10.tar.gz'
head 'http://nginx.org/download/nginx-1.1.9.tar.gz'
if ARGV.build_head?
md5 '711536767ce9127b1ffcc5043063bc84'
else
[
{
city: "Montreal",
first_name: "Istvan",
id: 1,
last_name: "Pusztai",
state: "Quebec",
avatar_url: "https://secure.gravatar.com/avatar/44c6f8371be4ee1612256855a3e35d12.png?s=48&d=http%3A%2F%2Frobohash.org%2F44c6f8371be4ee1612256855a3e35d12.png%3Fsize%3D48x48%26bgset%3Dany"
},
{
{
city: "Montreal",
first_name: "Istvan",
id: 1,
last_name: "Pusztai",
state: "Quebec",
avatar_url: "https://secure.gravatar.com/avatar/44c6f8371be4ee1612256855a3e35d12.png?s=48&d=http%3A%2F%2Frobohash.org%2F44c6f8371be4ee1612256855a3e35d12.png%3Fsize%3D48x48%26bgset%3Dany"
}
@istvanp
istvanp / cron syntax regex.php
Created February 21, 2010 08:05
Cron expression syntax check (excluding special operators except for * and /)
<?php
$cron = "*/5 * * * * *";
$result = preg_match(
"/(\*|[0-5]?[0-9]|\*\/[0-9]+)\s+"
."(\*|1?[0-9]|2[0-3]|\*\/[0-9]+)\s+"
."(\*|[1-2]?[0-9]|3[0-1]|\*\/[0-9]+)\s+"
."(\*|[0-9]|1[0-2]|\*\/[0-9]+|jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\s+"
."(\*\/[0-9]+|\*|[0-7]|sun|mon|tue|wed|thu|fri|sat)\s*"
."(\*\/[0-9]+|\*|[0-9]+)?/i", $cron, $matches);