Skip to content

Instantly share code, notes, and snippets.

View unixc3t's full-sized avatar
💢
coding

rudy unixc3t

💢
coding
View GitHub Profile
@unixc3t
unixc3t / Error_Terminal
Last active April 7, 2017 13:58 — forked from rrmartins/Error_Terminal
Solve Error Devise with RSpec and Rails 4 uninitialized constant ControllerMacros
.../spec/spec_helper.rb:27:in `block (2 levels) in <top (required)>': uninitialized constant ControllerMacros (NameError)
@unixc3t
unixc3t / controller_spec.rb
Last active May 1, 2017 07:57
rspec code snippet
# test get /
it 'get index' do
expect(get: "/").to route_to(controller: "links",
action: "index")
end
it 'get the about page' do
get :about
p response
@unixc3t
unixc3t / Array.java
Created April 14, 2017 05:50 — forked from jnwhiteh/Array.java
An example of implementing Iterable and Iterator in Java
import java.util.Iterator;
import java.util.NoSuchElementException;
// Introduction:
//
// This is an example class meant to illustrate several differen concepts:
// * The use of type parameters (i.e. Java generics)
// * Implementing an iterator over some collection, in this case an array
// * Implementing the Iterable interface, which enables your collection
// to work with the Java simple for loops, i.e. (for String s : list)
@unixc3t
unixc3t / app_build.gradle
Created April 16, 2017 01:04
kotlin for android studio config
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "zl.com.kotlinapp"
minSdkVersion 15
targetSdkVersion 25
@unixc3t
unixc3t / plugin.sh
Created June 29, 2017 07:02
Create rspec rails plugin
# http://stackoverflow.com/questions/8507798/rails-3-1-plugin-gem-dummy-test-app-rspec
# http://namick.tumblr.com/post/17663752365/how-to-create-a-gemified-plugin-with-rails-3-2-rspec
rails plugin new plugin_name --skip-test-unit --dummy-path=spec/dummy
cd plugin_name
# Add rspec-rails to gemspec dev deps
# s.add_development_dependency "rspec-rails"
bundle install
@unixc3t
unixc3t / install_elixir.md
Created July 24, 2017 09:35 — forked from rubencaro/install_elixir.md
Elixir installation guide

Elixir installation guide

Version numbers should be the ones you want. Here I do it with the last ones available at the moment of writing.

The simplest way to install elixir is using your package manager. Sadly, at the time of writing only Fedora shows the intention to keep its packages up to date. There you can simply sudo dnf install erlang elixir and you are good to go.

Anyway, if you intend to work with several versions of erlang or elixir at the same time, or you are tied to a specific version, you will need to compile it yourself. Then asdf is your best friend.

@unixc3t
unixc3t / recursion.erl
Last active January 9, 2018 10:31
erlang尾递归练习(recursion)
%%计算链表长度尾递归实现
lez(N) -> lez(N, 0).
lez([], Acc) -> Acc;
lez([_ | T], Acc) -> lez(T, Acc + 1).
%% 将某个元素重复n次返回一个链表
dulicate(0,_) ->[];
dulicate(N,DATA) -> [X | dulicate(N-1,X)].
@unixc3t
unixc3t / CompetingReceiver.java
Last active October 6, 2017 05:36
RabbitMQ Point-to-point communication
import com.rabbitmq.client.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
/**
* rudy
* 11:43 PM
@unixc3t
unixc3t / FanoutExchangeSenderDemo.java
Created October 5, 2017 07:45
Publish-subscribe communication
package ptos;
import ptop.Sender;
/**
* rudy
* 3:15 PM
* 10/5/17.
*/
public class FanoutExchangeSenderDemo {
@unixc3t
unixc3t / RequestReceiver.java
Created October 6, 2017 03:20
Request-reply communication
package rr;
import com.rabbitmq.client.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.UnsupportedEncodingException;