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 / 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 / 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;
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 / 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;
`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 / 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
@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 / gist:5317085
Last active December 15, 2015 20:18
C#? in my C++11 ?
#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 / chokesoncock.cpp
Last active December 15, 2015 11:38
chokes.
#include <iostream>
#include <string>
#include <boost/range/counting_range.hpp>
typedef boost::iterator_range<boost::counting_iterator<int> > counting_range_int_t;
counting_range_int_t operator "" _ri(char const* wtf, std::size_t len)
{
static std::istringstream parse;
parse.clear();
@nurettin
nurettin / lolrange.cpp
Created March 27, 2013 12:22
play with boost range and overloading string operator
#include <iostream>
#include <string>
#include <boost/range/counting_range.hpp>
typedef boost::iterator_range<boost::counting_iterator<int> > counting_range_int_t;
counting_range_int_t operator "" _ri(char const* wtf, std::size_t len)
{
static std::istringstream parse;
parse.clear();