Skip to content

Instantly share code, notes, and snippets.

require 'benchmark'
range = (0..900000000)
a = range.to_a
Benchmark.bmbm do |x|
x.report('each with array') do
a.each do |i|
i + 1
end
end
@yurirenko
yurirenko / gist:8665091
Last active January 4, 2016 19:09
Useful stuff
Why not use kill -9:
kill -9 $(ps aux | grep something | awk '{print $2}')
It doesn't give the process a chance to cleanly:
1) shut down socket connections
2) clean up temp files
@yurirenko
yurirenko / gist:4747250
Created February 9, 2013 21:44
asadmin db stuff
asadmin create-jdbc-connection-pool --datasourceclassname=org.apache.derby.jdbc.ClientDataSource --restype=javax.sql.DataSource --property portNumber=1527:password=APP:user=APP:serverName=localhost:databaseName={DATABASE_NAME}:connectionAttributes=;create\=true {POOL_NAME}
asadmin ping-connection-pool {POOL_NAME}
asadmin create-jdbc-resource --connectionpoolid webapptestpool jdbc/{POOL_NAME}
asadmin list-jdbc-resources
@yurirenko
yurirenko / pom.xml
Created February 9, 2013 21:15
main
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.me</groupId>
<artifactId>myapp</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>myapp</name>
<url>http://maven.apache.org</url>
<repositories>
@yurirenko
yurirenko / pom.xml
Created February 9, 2013 20:59
build for maven
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<inherited>true</inherited>
<version>3.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
@yurirenko
yurirenko / pom.xml
Last active December 12, 2015 08:49
various dependencies for maven
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
@yurirenko
yurirenko / pom.xml
Created February 9, 2013 20:48
maven repos
<repositories>
<repository>
<id>EclipseLink</id>
<url>http://download.eclipse.org/rt/eclipselink/maven.repo</url>
</repository>
<repository>
<id>Apache</id>
<url>http://repository.apache.org/snapshots</url>
</repository>
<repository>
@yurirenko
yurirenko / gist:4745330
Created February 9, 2013 13:48
maven create new project
mvn archetype:generate -DgroupId={project-packaging} -DartifactId={project-name} -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
@yurirenko
yurirenko / gist:4034038
Last active October 12, 2015 13:28
various gems dependencies
sudo apt-get install libxslt-dev libxml2-dev libreadline-dev zlib1g-dev libssl-dev libcurl3 libcurl3-gnutls libcurl4-openssl-dev imagemagick libmagickwand-dev
@yurirenko
yurirenko / hack.sh
Created March 31, 2012 14:13 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#