Skip to content

Instantly share code, notes, and snippets.

UPDATE `inlib-migration`.`books_ebooks_links` SET `name`='Extreme Programming Explained - Kent Beck.pdf' WHERE `id`='1';
UPDATE `inlib-migration`.`books_ebooks_links` SET `name`='The Art of Application Performance Testing – Help for Programmers and Quality Assurance.pdf' WHERE `id`='11';
UPDATE `inlib-migration`.`books_ebooks_links` SET `name`='effective-javascript.epub' WHERE `id`='76';
UPDATE `inlib-migration`.`books_ebooks_links` SET `name`='Practices of an Agile Developer. Working in the Real World.pdf' WHERE `id`='75';
UPDATE `inlib-migration`.`books_ebooks_links` SET `name`='effective-javascript.pdf' WHERE `id`='77';
UPDATE `inlib-migration`.`books_ebooks_links` SET `name`='Джони Айв. Легендарный дизайнер Apple.fb2' WHERE `id`='78';
UPDATE `inlib-migration`.`books_ebooks_links` SET `name`='Web UI Design for the Human Eye – Colors, Space, Contrast.pdf' WHERE `id`='50';
UPDATE `inlib-migration`.`books_ebooks_links` SET `name`='Interaction Design - Best Practices – Mastering Time, Responsiveness, and Behav
function processData(input) {
const r = /<a.*href\s*=\s*["']([^"']*)["'][^>](.*)<\/a>/;
console.log(r);
const text = input
.split(/\n/)
.slice(1)
.join('')
.split(/<\s*a[\s]/)
.map(s => '<a ' + s)
.forEach(l => proc(r, l));
expect(userService.save(EasyMock.capture(userEntity))).andAnswer(() -> {
userEntity.getValue().setUserId(newTaskId);
return createdTask.getValue();
});
@FreeFly19
FreeFly19 / Main.java
Created October 23, 2017 09:57
Multithreading procedure calls
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.LinkedList;
import java.util.Queue;
import java.util.concurrent.*;
@FreeFly19
FreeFly19 / example.json
Last active September 10, 2017 15:05
Athena
[
{
"content": "What is your name?",
"answers":[{
"id": "1",
"content": "sadsf"
},{
"id": "2",
"content": "asdas"
},{
@FreeFly19
FreeFly19 / FileController.java
Created March 21, 2017 08:42
Getting file from Controller Spring WEB MVC
@GetMapping(value = "/{documentId}/content")
public ResponseEntity<FileSystemResource> downloadContent(@PathVariable("documentId") Long documentId) {
FileSystemResource fileSystemResource = documentService.getContent(documentId);
return ResponseEntity
.ok()
.contentType(MediaType.valueOf(documentService.getContentType(documentId)))
.body(fileSystemResource);
@FreeFly19
FreeFly19 / fobonacci.js
Created February 1, 2017 15:35
Fib with caching
var fibonacci = (function () {
var cache = [];
return function fibo(n) {
if (cache[n]) return cache[n];
return cache[n] = n == 0 ? 0 :
n == 1 ? 1 :
fibo(n-1) + fibo(n-2);
};
@FreeFly19
FreeFly19 / Main.java
Created January 31, 2017 22:53
Downloading HTML through HTTP (http client example)
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
URL url = new URL("http://example.com");
URLConnection urlConnection = url.openConnection();
InputStream inputStream = urlConnection.getInputStream();
@FreeFly19
FreeFly19 / Main.java
Created January 30, 2017 17:08
Gson example
import com.google.gson.Gson;
public class Main {
public static void main(String[] args) {
Gson gson = new Gson();
Human human = new Human();
human.setAge(21);
human.setName("Sasha");
String humanJson = gson.toJson(human);
package com.company;
public class Main {
public static void main(String args[]) {
for (int i = 1; i < 10; i++) {
for (int j = 1; j < 10; j++) {
if (i < j) {
System.out.print(" # ");
} else {
System.out.print(i*j + " ");