Skip to content

Instantly share code, notes, and snippets.

based on http://stackoverflow.com/a/19346375/1211174
UPDATE `reports` r
INNER JOIN
`reportstemp` as t
ON
`r`.`REPORT_ID`= `t`.`REPORT_ID`
SET
`r`.`LAST_MODIFIED` = `t`.`LAST_MODIFIED`,
`r`.`modifier_id` = `t`.`modifier_id`
@oak-tree
oak-tree / gist:6fadc29cf852a3f874eb
Created August 26, 2014 10:33
MySql: search for all tables and db with collation different than utf_8_general_c
SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, COLLATION_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLLATION_NAME != 'utf8_general_ci'
LIMIT 0 , 30
Hibernate:
select
count(reportqs0_.REPORT_ID) as col_0_0_
from
reports reportqs0_
inner join
reports_projects projects1_
on reportqs0_.REPORT_ID=projects1_.report_id
inner join
projects project2_
@oak-tree
oak-tree / gist:9f710374d33fbb2caf03
Created September 3, 2014 14:52
select all records that doesn't have relation to another table
SELECT rp.report_id, rp.project_id, rp.project FROM `reports_projects` as rp where rp.project not in (select p.CODE from projects as p) limit 50
@oak-tree
oak-tree / git start point
Last active August 29, 2015 14:08
git start point
##version control:
http://git-scm.com/video/what-is-version-control
##git installing:
http://git-scm.com/
##git learning:
http://git-scm.com/documentation
https://training.github.com/kit/downloads/github-git-cheat-sheet.pdf
@oak-tree
oak-tree / gist:872010e8d29e59e9cb42
Last active August 29, 2015 14:14
Android crop image - psudo code
PictureCallback myPictureCallback_JPG = new PictureCallback(){
@Override
public void onPictureTaken(byte[] data, Camera arg1) {
// TODO Auto-generated method stub
try {
private final INT_QUALITY = 2;
BitmapFactory.Options options=new BitmapFactory.Options();
options.inSampleSize = INT_QUALITY;
@oak-tree
oak-tree / markAllBackgrounds
Last active August 29, 2015 14:14
mark all border in page
//add javascript line into your bookmark and click on a page
//known bug: if jquery is not loaded this will only work on the 2nd click
javascript: (function() { if (!window.jQuery) { var script = document.createElement('script'); script.src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js";
document.body.appendChild(script); } if (window.markAllElementsBackground) { $('*').each(function() { $(this).css('background-color',$(this).data('save-background-color-data')) }); window.markAllElementsBackground = false; } else { $('*').each(function() { $(this).data('save-background-color-data', $(this).css('background-color')); var color = "#" + Math.floor(Math.random() * 0xFFFFFF).toString(16);$(this).css('background-color', color )}); window.markAllElementsBackground = true ; }})();
@oak-tree
oak-tree / term filter
Created April 15, 2015 08:17
mysql key,value query with multiply keys
SELECT term_id,count(name) as counter FROM `tbl_term_character`
WHERE
(name="Size" && (value & b'10'))
||
(name="HeadColors" && (value & b'110'))
group by term_id
having counter = 2
@oak-tree
oak-tree / pom.xml
Last active August 29, 2015 14:19
pom.xml
<env>production</env>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.core.version>4.0.6.RELEASE</spring.core.version>
<spring.security.core.version>3.2.4.RELEASE</spring.security.core.version>
<spring.data.jpa.version>1.6.2.RELEASE</spring.data.jpa.version>
<spring.test.version>4.0.6.RELEASE</spring.test.version>
<cglib.version>3.1</cglib.version>
<org.javassist.version>3.18.2-GA</org.javassist.version>
<aspectj.version>1.8.1</aspectj.version>
@oak-tree
oak-tree / fixMapingGridToPreview
Last active August 29, 2015 14:20
mapping grid to preview
//new idea to calculate instead of the *FIRST setRectToRect & Translation*
//note 1: We do not want to resize the grid - the grid window in his original size
//note 2: We acully just want to move the grid from his left top corner to the center of the preivew
//note 3: The **SECOND** setRectToRect should be keept because this is the mapping between the *preview* and the *real image*
Bitmap bitmapPicture = BitmapFactory.decodeByteArray(data, INT_START, data.length);
RectF previewRect = new RectF(0, 0, previewWidth, previewHeight);
RectF pictureRect = new RectF(0, 0, bitmapPicture.getWidth(), bitmapPicture.getHeight());
//RectF nativeResRect = new RectF(0, 0, screenWidth, screenHeight); // we actully dont care about the native res because we have the grid coordiantes
RectF resultRect = new RectF(0, gridTop, gridRight, gridBottom);
final Matrix scaleMatrix = new Matrix();