Skip to content

Instantly share code, notes, and snippets.

View seabre's full-sized avatar

Sean Brewer seabre

  • CrowdFiber
  • Chattanooga, TN
View GitHub Profile
@endolith
endolith / frequency_estimator.py
Last active May 8, 2024 17:59
Frequency estimation methods in Python
from __future__ import division
from numpy.fft import rfft
from numpy import argmax, mean, diff, log, nonzero
from scipy.signal import blackmanharris, correlate
from time import time
import sys
try:
import soundfile as sf
except ImportError:
from scikits.audiolab import flacread
@anildigital
anildigital / client.js
Created April 9, 2011 10:16
Twitter streaming API example twitter-node and socket.io
<!DOCTYPE HTML>
<head>
<title>Codesnippit NodeJS Twitter Tracker Client</title>
</head>
<body>
<ul></ul>
<script>
(function() {
var script = document.createElement("script");
script.src = "http://code.jquery.com/jquery.min.js";
@johnthethird
johnthethird / cap_notify.rb
Created May 4, 2011 20:02 — forked from rtekie/cap_notify.rb
Capistrano deployment email notifier for Rails 3
=begin
Capistrano deployment email notifier for Rails 3
Do you need to send email notifications after application deployments?
Christopher Sexton developed a Simple Capistrano email notifier for rails. You can find details at http://www.codeography.com/2010/03/24/simple-capistrano-email-notifier-for-rails.html.
Here is Rails 3 port of the notifier.
The notifier sends an email after application deployment has been completed.
@gertig
gertig / devise_ajax_signup
Created August 17, 2011 19:31
Devise Ajax Signup
#registrations_controller.rb
class RegistrationsController < Devise::RegistrationsController
def create
params[:user][:password_confirmation] = params[:user][:password]
super
end
end
<!-- Inside any View --->
<%= form_for(:user, :url => "#", :html => { :id => "ajax_signup"}) do |f| %>
@seabre
seabre / replace_text_in_all_files.sh
Created September 16, 2011 17:26
Find and Replace Text in All Files Within a Directory Tree
find . -type f -print0 | xargs -0 sed -i 's/oldword/newword/g'
@seabre
seabre / one_month_ahead.rb
Created September 16, 2011 18:21
Get Datetime in the Currently Set Timezone in Rails for the Beginning of the Next Month
#Get datetime for the beginning of the next month in the timezone that's currently set.
one_month_ahead = Time.zone.now.at_beginning_of_month.next_month
#You can format the datetime the way you want as well.
one_month_ahead = Time.zone.now.at_beginning_of_month.next_month.strftime("%Y-%m-%d %T %z")
@seabre
seabre / get_columns_for_rails_admin.rb
Created September 30, 2011 17:02
Get Columns From Table Formatted For Configuration in Rails Admin
Model.columns.map {|c| puts "field :#{c.name}"}
@watson
watson / ability.rb
Created October 5, 2011 09:50
Active Admin CanCan integration with shared front/backend User model and multi-level autherization
# app/models/ability.rb
# All front end users are authorized using this class
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
can :read, :all
@seabre
seabre / basic_html5_template.html
Created October 15, 2011 07:58
Basic HTML5 Template
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Basic HTML5 Template</title>
<link href="stylesheets/style.css" rel="stylesheet" type="text/css" media="screen" />
<script src="example.js"></script>
</head>
<body>
@seabre
seabre / gist:1664683
Created January 23, 2012 18:29
Dump and Restore MySQL Database

#Dump and Restore MySQL DB Quick Ref

##Dump The MySQL Table

mysqldump -u username -p -r my_output.sql my_database

##Compress Output with 7zip using the PPMd Algorithm

7z a -t7z my_output.7z my_output.sql -m0=PPMd