Skip to content

Instantly share code, notes, and snippets.

@linusthe3rd
linusthe3rd / Reverse.java
Last active December 12, 2015 05:59
reverse a string in java
class Reverse {
public static void main(String[] args) {
reverse("abcde");
}
public static void reverse(String str){
char[] str_arr = str.toCharArray();
int start = 0,
end = str_arr.length-1;
@linusthe3rd
linusthe3rd / iptables.rb
Created July 12, 2012 17:17
The commands needed to set an iptables configuration from an ERB template in Chef.
template "/etc/sysconfig/iptables" do
source "iptables.erb"
owner "root"
group "root"
mode "0600"
end
# Ensure that the iptables file adheres to the selinux requirements
execute "chcon" do
command "chcon system_u:object_r:system_conf_t:s0 /etc/sysconfig/iptables"
args = ['-f', 'my_build.xml', 'my_target1']
task :call_ant do
ant args
end
@linusthe3rd
linusthe3rd / gist:1214669
Created September 13, 2011 18:48
mygem gem spec
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require 'mygem/version'
Gem::Specification.new do |s|
s.name = "MyGem"
s.version = MyGem::VERSION
s.authors = ["strife25"]
s.email = [""]
@linusthe3rd
linusthe3rd / gist:1214651
Created September 13, 2011 18:43
gem folder structure
mygem/
lib/
mygem/
system_gateway.rb
version.rb
providers/
build_provider.rb
engine_provider.rb
@linusthe3rd
linusthe3rd / gist:1085443
Created July 15, 2011 20:03
Hadoop Login Failure stacktrace
11/07/15 19:53:07 ERROR namenode.NameNode: java.io.IOException: failure to login
at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:408)
at org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:384)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.setConfigurationParameters(FSNamesystem.java:420)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.<init>(FSNamesystem.java:391)
at org.apache.hadoop.hdfs.server.namenode.NameNode.format(NameNode.java:1240)
at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1348)
at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1368)
Caused by: javax.security.auth.login.LoginException: java.lang.NullPointerException
at com.ibm.security.auth.module.LinuxLoginModule.login(LinuxLoginModule.java:165)
@linusthe3rd
linusthe3rd / grade_select.erb
Created May 18, 2011 18:00
Rails - Create a select tag for grades K-12
<%= f.label :grade %>
<%= f.select(:grade, (["K"] | (1..12).to_a))%>
@linusthe3rd
linusthe3rd / gist:947469
Created April 28, 2011 22:22
POST request output
SQL (2.8ms) describe `roles_users`
SQL (2.1ms) describe `camps_users`
SQL (3.4ms) describe `camps_users`
SQL (2.0ms) describe `campers_camps`
SQL (2.8ms) describe `campers_camps`
SQL (2.1ms) describe `roles_users`
Loaded suite test/functional/camp/contacts_controller_test
Started
SQL (0.1ms) BEGIN
SQL (0.7ms) SHOW TABLES
test "get collection of open programs" do
get :index, :camp_id => camps(:bolo).uri, :open => true
assert_response :success
programs = assigns(:programs)
programs.each do |program|
program.program_populations.each do |pop|
assert_not_equal pop.current_population, pop.max_population
end
def get_camp
@camp = Camp.find_by_uri(params[:camp_id])
if !@camp
#call parent 404 method because no record was found
#ActiveRecord::RecordNotFound is not being called
self.render_400
end
end