Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>
char *g_data;
size_t g_size;
size_t savedata(void *ptr, size_t size, size_t nmemb, void *stream)
{
require 'ffi-inliner'
module C
extend Inliner
inline do |b|
b.c_raw '#include <stdio.h>
#include <string.h>
'
end
inline '
int main(){
#include <stdio.h>
int main(){
FILE *f;
f=fopen("data.txt","w");
int i=0;
for(i=0;i<10;i++)
fprintf(f,"thisi is a test %d\n",i);
fclose(f);
#include <stdio.h>
int main(){
FILE *ff;
char s[255];
ff=fopen(__FILE__,"r");
int num=0;
while(fgets(s,255,ff)){
num++;
#http://www.infoq.com/cn/news/2009/10/21-ruby-web-middlewares
module Rack
class NoIE
def initialize(app, options = {})
@app = app
@options = options
@options[:redirect] ||= 'http://www.microsoft.com/windows/internet-explorer/default.aspx'
@options[:minimum] ||= 7.0
end
module Rack
class ChromeFrame
def initialize(app, options={})
@app = app
end
def call(env)
status, headers, response = @app.call(env)
if env['HTTP_USER_AGENT'] =~ /MSIE/ && response.content_type == 'text/html'
# This is actually available as a gem: gem install rack-rewrite
# Full source code including tests is on github: http://github.com/jtrupiano/rack-rewrite
module Rack
# A rack middleware for defining and applying rewrite rules. In many cases you
# can get away with rack-rewrite instead of writing Apache mod_rewrite rules.
class Rewrite
def initialize(app, &rule_block)
@app = app
@rule_set = RuleSet.new
http://www.jbarnette.com/2009/08/27/on-rake.html
#http://github.com/pluginaweek/state_machine
require 'state_machine'
class A
state_machine :initial=>:stop do
event :change do
transition :stop=>:start,:start=>:stop
end
before_transition do |a,_|
#geany: http://q.sohu.com/forum/5/topic/2893314
require 'activerecord'
ActiveRecord::Base.establish_connection :adapter=>"sqlite3",
:database=>"a.db"
ActiveRecord::Schema.define do
create_table "posts",:force=>true do |t|
t.string :title
end
end