Skip to content

Instantly share code, notes, and snippets.

@SafeAF
SafeAF / _form.html.erb
Created April 1, 2023 16:27 — forked from dalezak/_form.html.erb
Stimulus.js Toggle Controller to show and hide form elements based on select value
<div class="form-group">
<%= form.label :type, "Type", class: "font-weight-bold" %>
<%= form.select :type, ['TextQuestion', 'UrlQuestion'], { include_blank: true }, { class: "form-control", data: { action: "input->toggle#changed", target: "toggle.select" } } %>
</div>
<div class="form-group">
<%= form.label :name, "Name", class: "font-weight-bold" %>
<%= form.text_field :name, class: "form-control" %>
</div>
<div class="form-group" data-target="toggle.element" data-values="UrlQuestion">
<%= form.label :url, "URL", class: "font-weight-bold" %>
@SafeAF
SafeAF / google-dorks
Created November 22, 2020 02:40 — forked from stevenswafford/google-dorks
Listing of a number of useful Google dorks.
" _ _ "
" _ /|| . . ||\ _ "
" ( } \||D ' ' ' C||/ { % "
" | /\__,=_[_] ' . . ' [_]_=,__/\ |"
" |_\_ |----| |----| _/_|"
" | |/ | | | | \| |"
" | /_ | | | | _\ |"
It is all fun and games until someone gets hacked!
@SafeAF
SafeAF / linux_performance.md
Created July 19, 2017 13:53 — forked from marianposaceanu/linux_performance.md
Linux simple performance tweaks

Linux simple performance tweaks

Change the I/O Scheduler

Open $ vim /etc/default/grub then add elevator=noop next to GRUB_CMDLINE_LINUX_DEFAULT. Run $ update-grub and $ cat /sys/block/sda/queue/scheduler to be sure that noop is being used:

$ vim /etc/default/grub
$ update-grub
$ cat /sys/block/sda/queue/scheduler

[noop] deadline cfq

@SafeAF
SafeAF / .gitconfig
Created February 21, 2017 21:59 — forked from pksunkara/config
Sample of git config file (Example .gitconfig)
[user]
name = Pavan Kumar Sunkara
email = [email protected]
[core]
editor = vim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile = ~/.gitignore
[sendemail]
smtpencryption = tls
smtpserver = smtp.gmail.com
@SafeAF
SafeAF / Rakefile
Created February 18, 2017 22:23 — forked from robhurring/Rakefile
Delayed Job with Sinatra -- without sinatra specific gems, etc.
task :environment do
require './dj-sinatra'
end
namespace :jobs do
desc "Clear the delayed_job queue."
task :clear => :environment do
Delayed::Job.delete_all
end
@SafeAF
SafeAF / notify-send-replacement.sh
Created September 15, 2016 04:03
Notify-send replacement using gdbus
#!/usr/bin/env bash
# notify-send.sh - drop-in replacement for notify-send with more features
# Copyright (C) 2015 Vyacheslav Levit <[email protected]>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@SafeAF
SafeAF / .Dockerfile
Last active October 10, 2016 23:48
Here be dotfiles for a variety of applications and gem libraries etc. Procfiles, Rakefiles, Gemfiles etc
FROM ruby:2.3
ENV LC_ALL C.UTF-8
RUN apt-get update -y \
&& apt-get install -y python-pip \
&& pip install pygments
RUN mkdir -p /app/vendor
WORKDIR /app
@SafeAF
SafeAF / switch.rb
Created August 31, 2016 01:23 — forked from jbr/switch.rb
ruby 1.9.2 case-like switch
# In response to:
# http://mlomnicki.com/ruby/tricks-and-quirks/2011/02/10/ruby-tricks2.html
# Ruby 1.9.2 has some neat stuff that lets us make a readable
# alternative case statement that calls each method in turn.
# 1.9.2 features used:
# * hashes are ordered in 1.9.2
# * cool JSON-style hash syntax
# * concise lambda syntax
@SafeAF
SafeAF / when-proc.rb
Created August 26, 2016 22:52 — forked from mrb/when-proc.rb
# ruby 1.9 supports 4 ways to call a proc! ex: f =->n {[:hello, n]}; f[:ruby]; f.call(:ruby); f.(:ruby)
#
# turns out, you can also call a proc via proc === :arg -- which means you can use proc's in when clauses!
# ruby doc: http://ruby-doc.org/ruby-1.9/classes/Proc.html#M001165
#
# ... kudos to @chadfowler for the tip!
#
# (note: works on 1.8.7 as well :-))
def am_i_awesome?