Skip to content

Instantly share code, notes, and snippets.

@borsch
borsch / gist:bf75d4f9d009d9c5f84c
Created August 21, 2015 13:48
facebook make post with js
<html>
<head>
<script src="https://connect.facebook.net/en_US/sdk.js"></script>
</head>
<body>
<script type="text/javascript">
var PAGE_ID = 'page_id';
var PAGE_ACCESS_TOKEN = 'access_tooken_to_page';
window.fbAsyncInit = function() {
FB.init({
// script.js
(function(exports){
// public function
// can be accessed outside of this file
exports.publicFunction = function(param1, param2){
};
// private function
@borsch
borsch / part_of_pom.xml
Last active September 16, 2016 07:05
create excutable jar with maven
<build>
<plugins>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
@borsch
borsch / load.java
Created September 16, 2016 07:04
down load file from url with java
String url = "http://my-site.com/text.txt";
String fileName = "/path/to/file/to/save/text.txt";
URL website = new URL(url);
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(fileName);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
@borsch
borsch / must_know
Created September 29, 2016 15:04
things_developer_must_know
точно мережі
точно мені не вистачає адміністрування юнікс систем
дуже часто треба ПХП
лінійка JavaScript від сервера до клієнта
мені не вистачає реально Java EE
багатопоточність
робота з базами
XML + JSON
автоматичне і мануальне тестування
continuous integration
https://en.wikipedia.org/wiki/JPEG_File_Interchange_Format
http://dev.exiv2.org/projects/exiv2/wiki/The_Metadata_in_JPEG_files
http://paulbourke.net/dataformats/bitmaps/
@borsch
borsch / rect.js
Created May 15, 2017 20:26
create svg rect
var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
rect.setAttribute('x', x)
rect.setAttribute('y', y)
rect.setAttribute('width', width)
rect.setAttribute('height', height)
rect.setAttribute('fill', 'rgb(1, 100, 1)');
http://arduino-diy.com/arduino-oled-displey
oled -> leonardo
GND -> GND
VDD -> 3.3V
SCK -> D3
SDA -> D2
get i2c port
http://playground.arduino.cc/Main/I2cScanner
@borsch
borsch / maven_jar_build
Last active July 13, 2017 19:17
java build maven single jar with dependencies
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
@borsch
borsch / script.js
Created August 18, 2017 15:05
upload file with data via ajax to server
var payload = new FormData();
payload.append('file', $('#my_file_input')[0].files[0]);
payload.append('some_field', 'foo');
var request = new XMLHttpRequest();
request.open('PUT'|'POST', '/my/api/upload/url');
request.setRequestHeader('Accept', 'application/json');
request.onload = function () {
var response = request.response;