Skip to content

Instantly share code, notes, and snippets.

View hodlbirb's full-sized avatar

Dmitry hodlbirb

  • Hong Kong
View GitHub Profile
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="jpa">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
@hodlbirb
hodlbirb / pom.xml
Last active February 29, 2016 08:52
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.fx</groupId>
<artifactId>quickstart</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
package Model;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
@Entity(name = "persons")
public class Person implements Serializable {
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
@hodlbirb
hodlbirb / Main.java
Last active February 29, 2016 09:13
package Main;
import Model.Person;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
public class Main {
Exception in thread "main" java.lang.IllegalArgumentException: Unknown entity: Main.Main$1
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:1149)
at Main.Main.main(Main.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
@hodlbirb
hodlbirb / problem.txt
Last active May 1, 2016 18:12
string “weightfoxtourist” represents as 2468
Problem
You just made a new friend at an international puzzle conference,
and you asked for a way to keep in touch. You found the following note
slipped under your hotel room door the next day:
"Salutations, new friend! I have replaced every digit of my phone number
with its spelled-out uppercase English representation ("ZERO", "ONE", "TWO",
"THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE" for the digits
0 through 9, in that order), and then reordered all of those letters in some
/*
5. The total number of students travelling to a specific country in a multi city
trip operated by a specified coach in given date.
Result should contain both detailed breakup & summary for above mentioned
categories along with overall summary.
*/
SELECT COUNT(student_id) AS `Total number of students`, country_name, vin AS `Coach No`
FROM country
#!/bin/bash
# -c file - compress file
# -d file - decompress file
while getopts ":c:d:" opt; do
case $opt in
c ) cut -d' ' -f1,3,4,5,6 $OPTARG | gzip -k -9 > comp.gz;;
d ) gzip -d $OPTARG --stdout | sed -e "s/\([0-9]\{2\}:[0-9]\{2\}\)\(:[0-9]\{2\}\)/\1\2 \1/" > decomp.txt;;
esac
@hodlbirb
hodlbirb / sqrt.go
Last active January 31, 2017 22:24
Hand-coded sqrt func with tail recursion
package main
import (
"fmt"
"math"
"math/big"
)
func Sqrt(x float64) float64 {
if x == 0 {
@hodlbirb
hodlbirb / 3 digit polyndrom
Created February 3, 2017 11:03
Output: 994009
def main():
memo = 0
for i in range(1, 999):
for j in reversed(range(1,999)):
temp = i * j
s = str(temp)
if (s[0] == s[-1] and temp > memo):
memo = temp
print(memo)