Skip to content

Instantly share code, notes, and snippets.

#{rich:clientId('')} // talepForm:mobisNoLabel
#{rich:element('')} // document.getElementById('talepForm:mobisNoLabel')
#{rich:component('')} // RichFaces.component('talepForm:mobisNoLabel')
#{rich:findComponent('')} // javax.faces.component.html.HtmlOutputLabel@48d139c
discourse make user admin
# rails c
> u = User.where(email: 'myemail@example.com').first
> u.admin = true
> u.save
token = u.email_tokens.create(email: u.email)
EmailToken.confirm(token.token)
// starting rails
redis-server /usr/local/etc/redis.conf # to start server
redis-cli # connect server
redis-cli shutdown # shutdown server
psql postgres # postgres -> dbname
# to quit
\q
select * from pg_stat_activity;
show config_file;
# list of tables
// start
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
// stop
pg_ctl -D /usr/local/var/postgres stop -s -m fast
@mkayman
mkayman / java-process-builder
Created July 29, 2013 14:36
java process builder
public class Main {
public static void main(String[] args) throws Exception{
ProcessBuilder pb = new ProcessBuilder("winmergeu",
"D:\\path\\to\\file.java",
"D:\\path\\to\\file2.java");
pb.start();
for(String i : pb.environment().keySet()){
System.out.println(i + ": " + pb.environment().get(i));
@mkayman
mkayman / A.java
Last active December 18, 2015 21:48
Escaping "this" in constructor
public class A {
B b;
C c;
public A() {
b = new B(this);
c = new C();
}
public void hello() {
@mkayman
mkayman / weighted-random-selection
Created May 30, 2013 20:15
weighted-random-selection
package com.mkayman;
import java.util.Arrays;
import java.util.List;
public class Main {
public static void main(String[] args) {
List<Item> items = Arrays.asList(new Item("item1", 40), new Item(
"item2", 10), new Item("item3", 10), new Item("item4", 10),
@mkayman
mkayman / windows-robocopy
Created May 22, 2013 07:29
windows robocopy
robocopy "D:\source\path" "C:\dest\path" a1.txt a2.txt a3.txt
pause
@mkayman
mkayman / oracle-java-version
Created May 7, 2013 08:33
Checking java version in oracle database
create or replace function get_java_property (prop varchar2) return varchar2 is
language java
name 'java.lang.System.getProperty(java.lang.String) return java.lang.String';
and then
select get_java_property('java.version') from dual;