Skip to content

Instantly share code, notes, and snippets.

View rifttech's full-sized avatar
🐳
Focusing

Arthur Abramov rifttech

🐳
Focusing
View GitHub Profile
@rifttech
rifttech / squashing
Created January 6, 2018 18:27
Squashing commits on master
git log # select sha of commit
git rebase -i <sha>
git push --force
@rifttech
rifttech / java.bnf
Created October 6, 2015 07:55
Java Syntax Specification
Java Syntax Specification
Programs
<compilation unit> ::= <package declaration>? <import declarations>? <type declarations>?
Declarations
<package declaration> ::= package <package name> ;
<import declarations> ::= <import declaration> | <import declarations> <import declaration>
@rifttech
rifttech / cmdhell.bat
Last active August 29, 2015 14:24
cmd-hell
@Echo Off
:: Варианит 1
Set xOS=x64
If "%PROCESSOR_ARCHITECTURE%"=="x86" If Not Defined PROCESSOR_ARCHITEW6432 Set xOS=x86
Echo %xOS%
Pause
:: ===================================================================================
:: Варианит 2
Set xOS=x86
<assembly>
<id>dist</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<dependencySets>
<dependencySet>
@rifttech
rifttech / copy-conf.xml
Created June 25, 2015 19:26
maven copy config
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
public class BlockingQueue implements Queue {
private java.util.Queue queue = new java.util.LinkedList();
/**
* Make a blocking Dequeue call so that we'll only return when the queue has
* something on it, otherwise we'll wait until something is put on it.
*
* @returns This will return null if the thread wait() call is interrupted.
*/
public class MyWorker extends Thread {
private static int instance = 0;
private final Queue<String> queue;
public MyWorker(Queue queue) {
this.queue = queue;
setName("MyWorker:" + (instance++));
}
@Override
@rifttech
rifttech / truncate-time=in-getdate.sql
Last active August 29, 2015 14:19
SQL Server 2008 - Truncate time in 'Getdate'
select CONVERT(DATE,getdate(), 101) -- returns YYYY-MM-DD
/*OR...*/
select CAST(GETDATE() as Date) -- returns YYYY-MM-DD
@rifttech
rifttech / rm-dup-sql-srv2008.sql
Created April 22, 2015 10:13
removing duplicates from table(sql server 2008)
with cte as (
select row_number() over (
partition by
$column_names$
order by $orderby_column$ as rn
from $table_name$)
delete from cte
where rn > 1;
@rifttech
rifttech / nodejs-read-file.js
Last active August 29, 2015 14:19
nodejs io read file by line
//Synchronous:
var fs = require('fs');
var array = fs.readFileSync('file.txt').toString().split("\n").forEach(function(line){
console.log(line);
});
//Asynchronous:
var fs = require('fs');
fs.readFile('file.txt', function(err, data) {
if(err) throw err;