Skip to content

Instantly share code, notes, and snippets.

View dallarosa's full-sized avatar

Francisco Dalla Rosa Soares dallarosa

View GitHub Profile
@dallarosa
dallarosa / insert_after.js
Created December 20, 2010 09:34
Function for inserting some content (thread) after a marker(needle) inside a container (haystack). haystack should be and object.
function insert_after(haystack, needle, thread)
{
var browser=navigator.userAgent;
if((typeof haystack.innerText == 'undefined') || (!(browser.indexOf("MSIE")>0)))
{
var haystackText = haystack.innerHTML;
}
else
class Task < ActiveRecord::Base
attr_accessor :infile_file_name
attr_accessor :infile_content_type
attr_accessor :infile_file_size
attr_accessor :infile_updated_at
validates_presence_of :name
has_attached_file :infile, :path => ":rails_root/public/system/:user_id/:project_id/:id/:filename"
belongs_to :project
end
sqlite> select * from delayed_jobs;
1|0|0|--- !ruby/struct:Delayed::PerformableMethod
object: !ruby/object:TextAnalysis {}
method_name: :start
args: []
||2011-01-17 18:58:19.296379||||2011-01-17 18:58:19.296452|2011-01-17 18:58:19.296452
2|0|0|--- !ruby/struct:Delayed::PerformableMethod
object: !ruby/object:TextAnalysis {}
class TasksController < ApplicationController
def start
require("textanalysis.rb")
a = TextAnalysis.new
a.start
flash[:notice] = "Processing"
redirect_to :action => "show"
end
# encoding: utf-8
$KCODE="U"
require 'ftools'
require 'jcode'
require 'environment.rb' #環境に関する変数
require 'settings.rb' #タスクの設定
require "01morph.rb" #形態素解析のソースファイル
require "02freq.rb" #頻度計算のソースファイル
#METHOD CALLING THE DELAYED_JOB
def start
@user = User.find(params[:user_id])
@project = @user.projects.find(params[:project_id])
Delayed::Job.enqueue(TextAnalysis.new(@project.tasks.find(22)))
flash[:notice] = "Processing"
redirect_to :action => "show"
class Task < ActiveRecord::Base
attr_accessor :infile_file_name
attr_accessor :infile_content_type
attr_accessor :infile_file_size
attr_accessor :infile_updated_at
validates_presence_of :name
has_attached_file :infile, :path => ":rails_root/public/system/:user_id/:id/inputs/:filename"
belongs_to :user
end
@dallarosa
dallarosa / armain.java
Created January 26, 2011 07:10
audio recording method
MediaRecorder recorder = new MediaRecorder();
recorder.reset();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile("test/tmp.3gp");
try {
recorder.prepare();
@dallarosa
dallarosa / gist:814084
Created February 7, 2011 07:00
output from compilation of Broadcom's STA driver with linux kernel 2.6.37
CC [M] /home/dalla/Downloads/broadcom/src/wl/sys/wl_linux.o
/home/dalla/Downloads/broadcom/src/wl/sys/wl_linux.c: In function 'wl_attach':
/home/dalla/Downloads/broadcom/src/wl/sys/wl_linux.c:485:3: error: implicit declaration of function 'init_MUTEX'
make[2]: *** [/home/dalla/Downloads/broadcom/src/wl/sys/wl_linux.o] Error 1
make[1]: *** [_module_/home/dalla/Downloads/broadcom] Error 2
make[1]: Leaving directory `/usr/src/linux-2.6.37'
make: *** [all] Error 2
@dallarosa
dallarosa / uploadstate.js
Created May 5, 2011 07:56
checking the upload state with JS
<% form_for :lesson, @lesson, :url => {:action => "create"}, :html => { :multipart => true } do |form| %>
Nome: <%= form.text_field :name %><br/>
Descricao <%= form.text_field :description %><br/>
Video: <%= form.file_field :video %><br/>
<%= form.hidden_field :uuid, :value => @uuid%>
<%= form.submit %>
<% end %>
<div id="teste"></div>
<script type="text/javascript">
$("form").submit(