Skip to content

Instantly share code, notes, and snippets.

View danhper's full-sized avatar

Daniel Perez danhper

View GitHub Profile
def create
@contest = Contest.find(params[:contest_id])
participation = Participation.find_or_create_by_contest_id_and_user_id(@contest.id, current_user.id)
submission = participation.build_current_submission(:file => params[:file])
ai_file = participation.ai_files.find_or_create_by_filename(submission.file.filename)
ai_file.update_attributes(:language => params[:language])
ai_file.add_submission(submission)
submission.check
redirect_to @contest
class LoaderController < ApplicationController
def view_files
@users = User.includes(:loaders).all
end
end
@danhper
danhper / index.html
Created September 16, 2013 20:07
Focus contenteditable div
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>foobar</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script>
$(function() {
var $div = $('<div />').attr('contenteditable', 'true').text('foo');
$('#container').append($div);
09-22 00:04:48.131 7596-7634/? A/libc﹕ @@@ ABORTING: invalid address or address of corrupt block 0x6ef86b78 passed to dlfree
09-22 00:04:48.141 7596-7634/? A/libc﹕ Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 7634 (Thread-7989)
09-22 00:04:48.201 120-120/? I/DEBUG﹕ *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
09-22 00:04:48.201 120-120/? I/DEBUG﹕ Build fingerprint: 'google/nakasi/grouper:4.3/JWR66Y/776638:user/release-keys'
09-22 00:04:48.201 120-120/? I/DEBUG﹕ Revision: '0'
09-22 00:04:48.201 120-120/? I/DEBUG﹕ pid: 7596, tid: 7634, name: Thread-7989 >>> com.gameloft.android.ANMP.GloftDMHM <<<
09-22 00:04:48.201 120-120/? I/DEBUG﹕ signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaad
09-22 00:04:48.201 120-120/? I/DEBUG﹕ Abort message: '@@@ ABORTING: invalid address or address of corrupt block 0x6ef86b78 passed to dlfree'
09-22 00:04:48.841 124-459/? I/AudioFlinger﹕ BUFFER TIMEOUT: remove(4098) from active list on thread 0x40cf
@danhper
danhper / EdgeChromSupp.c
Last active December 27, 2015 05:49
Edgeなんたらmain関数
void main_EdgeChromaSuprression(void)
{
int n = 0;
int nSnrTotalLine = 0;
ImageInt* pInImg = NULL;
ImageInt* pOutImg = NULL;
FILE* snrFile = NULL;
FILE* confFile = NULL;
long lPosition = 0;
IPF3_SNR_PARAM ipf3SnrParam;
#include <stdio.h>
void set_int(int* target, int value)
{
*target = value;
}
int main(void)
{
int n = 8;
@danhper
danhper / nginx
Last active December 30, 2015 10:59
Nginx init script for passenger
#!/bin/sh
#
# http://stackoverflow.com/a/8020189
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
@danhper
danhper / redis.conf
Last active December 30, 2015 11:09
Redis configuration
# Redis configuration file example
# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
# /etc/X11/xorg.conf.d/10-synaptics.conf
Section "InputClass"
Identifier "touchpad catchall"
Driver "synaptics"
MatchIsTouchpad "on"
MatchDevicePath "/dev/input/event*"
Option "TapButton1" "1"
Option "TapButton2" "2"
Option "TapButton3" "3"
@danhper
danhper / aquaterm_install.md
Last active June 3, 2021 16:12
Installing Gnuplot with Aquaterm support on OSX 10.6+