Skip to content

Instantly share code, notes, and snippets.

@pottedmeat7
pottedmeat7 / createnewjspartial.js.erb
Created October 29, 2015 21:51
new create form with js partial
//hide bootstrap modal
waitingDialog.hide();
//append and show new empty form
jQuery(".newcontactholder").append("<%= escape_javascript(render 'new') %>");
jQuery(".newcontactholder").show();
//init autocomplete on name field
jQuery("#<%= @formID %> .searchContactNameField").autocomplete({
source: "/contact_name_autocomplete_search",
minLength: 3,
select: function(event, ui) {
@pottedmeat7
pottedmeat7 / deviseerrors.rb
Created October 29, 2015 21:56
devise helper to list errors in alert box
module DeviseHelper
def devise_error_messages!
return "" if resource.errors.empty?
messages = resource.errors.full_messages.map { |msg|
content_tag :li do
content_tag(:div, ' ', :class=>'glyphicon glyphicon-exclamation-sign') +
content_tag(:span, ' '+msg)
end
}.join
@pottedmeat7
pottedmeat7 / PollUSBActivity.java
Last active May 20, 2018 11:05
Android Activity to read from USB
//connects and reads from usb device
public class PollUSBActivity extends Activity implements View.OnClickListener {
private static final String TAG = "USBReader";
private TextView mLog;
private UsbManager mUsbManager;
private UsbDevice mDevice;
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
import unittest, time, re, sys
baseurl = sys.argv[1]
class Clickalllinksonpage(unittest.TestCase):
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
import unittest, time, re, sys
filepath = sys.argv[1]
class Openlinksinfile(unittest.TestCase):
namespace :figaro do
desc "Symlink application.yml to the release path"
task :symlink do
on roles :all do
execute :ln, "-sf #{shared_path}/application.yml #{release_path}/config/application.yml"
end
end
end
JS_PATH = "app/assets/javascripts/**/*.js";
Dir[JS_PATH].each do |file_name|
puts "\n#{file_name}"
puts Uglifier.compile(File.read(file_name))
end
before_filter :store_location
def store_location
# store last url - this is needed for post-login redirect to whatever the user last visited.
return unless request.get?
if ( !request.path.include?("/log-in") &&
!request.path.include?("/users/confirmation") &&
!request.path.include?("/users/password/new") &&
!request.path.include?("/users/password/edit") &&
!request.xhr?) # don't store ajax calls
@pottedmeat7
pottedmeat7 / encrypt.rb
Created October 28, 2019 22:24
encrypts any string using openssl key and ruby
require 'openssl'
require 'base64'
public_key_file = 'pubkey.pem';
string = ""
File.open(ARGV[0]).each_line do |line|
string += line
end
@pottedmeat7
pottedmeat7 / decrypt.rb
Created October 28, 2019 22:25
Decrypt string using openssl key and ruby
require 'openssl'
require 'base64'
private_key_file = 'privkey.pem';
password = 'this phrase is the clue to unlock the encryption'
encrypted_string = ""
File.open(ARGV[0]).each_line do |line|
encrypted_string += line