Skip to content

Instantly share code, notes, and snippets.

View nurettin's full-sized avatar
🏠
Working from home

Nurettin Onur TUĞCU nurettin

🏠
Working from home
View GitHub Profile
@nurettin
nurettin / csharpin.cpp
Created April 5, 2013 06:56
in my c++?!
#include <functional>
template <typename T>
struct Property
{
T value;
std::function<T()> getter;
std::function<void(T)> setter;
operator T(){ return getter(); }
void operator= (T wtf){ setter(wtf); }
@nurettin
nurettin / torquebox_warbler_war_error.txt
Created May 3, 2013 13:48
torquebox deploy war error
org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `cache_container' for nil:NilClass
at RUBY.manager(/home/torquebox/.rvm/gems/jruby-1.7.2/gems/torquebox-cache-2.3.0-java/lib/cache.rb:275)
at RUBY.cache(/home/torquebox/.rvm/gems/jruby-1.7.2/gems/torquebox-cache-2.3.0-java/lib/cache.rb:264)
at RUBY.initialize(/home/torquebox/.rvm/gems/jruby-1.7.2/gems/torquebox-cache-2.3.0-java/lib/cache.rb:72)
at RUBY.cache(/home/torquebox/.rvm/gems/jruby-1.7.2/gems/torquebox-cache-2.3.0-java/lib/active_support/cache/torque_box_store.rb:125)
at RUBY.initialize(/home/torquebox/.rvm/gems/jruby-1.7.2/gems/torquebox-cache-2.3.0-java/lib/active_support/cache/torque_box_store.rb:32)
at RUBY.lookup_store(/home/torquebox/.rvm/gems/jruby-1.7.2/gems/activesupport-3.2.13/lib/active_support/cache.rb:69)
at RUBY.Bootstrap(/home/torquebox/.rvm/gems/jruby-1.7.2/gems/railties-3.2.13/lib/rails/application/bootstrap.rb:54)
at RUBY.silence_warnings(/home/torquebox/.rvm/gems/jruby-1.7.2/gems/activesupport-3.2.13/lib/a
`app/admin/product.rb`
ActiveAdmin.register Product do
controller do
def permitted_params
params.permit(product_arts_attributes: [:uri])
end
end
form({ html: { multipart: true } }) do |f|
@nurettin
nurettin / counting_unique.cpp
Created August 3, 2013 08:44
counting unique
#include <cstdlib>
namespace pwned {
template <class ForwardIterator, class OutputIterator>
ForwardIterator counting_unique (ForwardIterator first, ForwardIterator last, OutputIterator out)
{
if (first==last) return last;
ForwardIterator result = first;
std::size_t count= 1;
include Java
require 'blpapi3.jar'
opts = com.bloomberglp.blpapi.SessionOptions.new
opts.server_host = 'localhost'
opts.server_port = 8194
session = com.bloomberglp.blpapi.Session.new opts
service = '//blp/refdata'
throw "Can't start Bloomberg" unless session.start && session.open_service(service)
@nurettin
nurettin / jvm
Created September 11, 2013 04:50
inonit.com creating a jvm from a c program (page saved from google cache)
Creating a JVM from a C Program
First, here's the completed C program for reference. Our program dispenses with niceties like error checking that you, of course, would like to do in your real programs:
#include <stdio.h>
#include <jni.h>
JNIEnv* create_vm() {
JavaVM* jvm;
JNIEnv* env;
@nurettin
nurettin / streaming.rb
Created September 11, 2013 14:30
streaming in jboss-torquebox
def stream_lol
headers['Cache-Control'] = 'no-cache'
response['Transfer-Encoding'] = 'chunked'
self.response_body = Enumerator.new do |y|
5.times do |i|
metin= "Paket #{i}: #{Time.now.to_s}<br/>"
sleep 1
Rails.logger.info metin
y<< metin
end
@nurettin
nurettin / becauseican.cpp
Created September 14, 2013 10:42
C++, because I can.
#include <iostream>
#include <map>
#include <boost/any.hpp>
#include <curl/curl.h>
typedef std::map<std::string, boost::any> params_t;
void open(params_t params)
{
if(boost::any_cast<bool>(params["session"]))
@nurettin
nurettin / create_class_otf.rb
Created October 2, 2013 07:37
create_class_otf.rb
x= Class.new Object do
def inspect
"lol!"
end
end
module Lol
end
Object.const_set("Wtf", x)
@nurettin
nurettin / .Xmodmap
Created October 23, 2013 16:34
X keyboard modification to convert [CapsLock] to [Tab] (because my tab key broke)
remove Lock = Caps_Lock
keycode 66 = Tab ISO_Left_Tab Tab ISO_Left_Tab
keycode 23 = Caps_Lock NoSymbol Caps_Lock