Skip to content

Instantly share code, notes, and snippets.

View aalvarado's full-sized avatar
😎

Adan Alvarado aalvarado

😎
View GitHub Profile
@endolith
endolith / Has weird right-to-left characters.txt
Last active April 30, 2024 12:48
Unicode kaomoji smileys emoticons emoji
ּ_בּ
בּ_בּ
טּ_טּ
כּ‗כּ
לּ_לּ
מּ_מּ
סּ_סּ
תּ_תּ
٩(×̯×)۶
٩(̾●̮̮̃̾•̃̾)۶
// Released under MIT license: http://www.opensource.org/licenses/mit-license.php
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function() {
var input = $(this);
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
Person = {
instance: function(name, lastname)
{
var base = this;
base._private = {}
base._public = {}
base._private.name = name;
base._private.lastname = lastname;
@aalvarado
aalvarado / changeLineRecorded.py
Created October 27, 2010 23:50
Snippet from my record line file for pythonscript plugin in n++
class FilePosition:
def __init__(self, bufferId):
self.bufferId = bufferId #sets the bufferId
self.filePositions = [] # where the modified lines will be stored
self.lastPos = 0
self.counter = 0
def addFilePosition(self, pos):
self._findDelete(pos) # checks if the line number is already in the list
@dhh
dhh / gist:1014971
Created June 8, 2011 18:09
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
@KINGSABRI
KINGSABRI / syn-poc.rb
Created June 8, 2012 20:31
Build TCP/IP packet from scratch by ruby , and send syn(or whatever you want) packet
#!/usr/bin/env ruby
# Full Contol on Ethnet, IP & TCP headers. Play with it ;)
# to test it: nc -lvp 4444
# as root: tcpdump -nvvvv 'tcp port 4444' -i wlan0 # change wlan0 to your interface
# or use packetfu to monitor as tcpdump
## cap = PacketFu::Capture.new(:iface => 'wlan0' , :promisc=> true)
## cap.show_live(:filter => 'tcp and port 4444')
# libpcap should be installed
# gem install pcaprub packetfu
@nuxlli
nuxlli / console.rb
Created July 10, 2012 17:43
To access url helpers (url_for, etc) from Rails console (Rails 3)
# Example from: http://snipplr.com/view/37063/
include Rails.application.routes.url_helpers
# set host in default_url_options:
default_url_options[:host] = "localhost"
# can then use:
url_for()
@maxivak
maxivak / send_data-send_file-remote-images-download
Created January 1, 2013 23:34
Rails. Download remote image as attachment in browser
# in controller
# for local files
send_file '/path/to/file', :type => 'image/jpeg', :disposition => 'attachment'
# for remote files
require 'open-uri'
url = 'http://someserver.com/path/../filename.jpg'
data = open(url).read
send_data data, :disposition => 'attachment', :filename=>"photo.jpg"
@mcmire
mcmire / table_helpers.rb
Last active December 18, 2015 23:19
Helper for use in RSpec/Capybara feature tests to find a table on a page and convert it into an array of arrays, so that you can make an assertion on it. Similar to Cucumber's #tableize but is better about stringifying cell content.
module TableHelpers
VALID_FORMATS = [:html, :text]
# Find a table on the page and convert it to an array of arrays.
#
# selector_or_node - A String CSS selector to find the table, or a
# Nokogiri::XML::Node object (if you already have a
# reference to the table).
# options - Optional hash:
# columns - An Integer or Range of Integers. Lets you