Skip to content

Instantly share code, notes, and snippets.

View NCNecros's full-sized avatar

Stanislav NCNecros

View GitHub Profile
@NCNecros
NCNecros / notepad.html
Created March 20, 2017 05:23 — forked from jdkanani/notepad.html
This bookmarklet gives you a code editor in your browser with a single click.
data:text/html, <style type="text/css">.e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div class="e" id="editor"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("editor");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
<!--
For other language: Instead of `ace/mode/ruby`, Use
Markdown -> `ace/mode/markdown`
Python -> `ace/mode/python`
C/C++ -> `ace/mode/c_cpp`
Javscript -> `ace/mode/javascript`
Java -> `ace/mode/java`
Scala- -> `ace/mode/scala`

Конфиги

Навигация

Различные способы перехода в режим вставки

i " вставить текст до курсора
@NCNecros
NCNecros / gist:c30f267a9c42d909bb23
Created June 3, 2015 07:40
Java 8 stream api map and flat map
package com.company;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class Main {
public static void main(String[] args) {
@NCNecros
NCNecros / gist:d2a24102ecdd7677c3a3
Created June 2, 2015 10:43
work with com.linuxense:javadbf:0.4.0
public void readDBF(String filename) throws FileNotFoundException, DBFException {
Object[] row;
Map<String, String> resultMap = new HashMap<>();
//Необходимый минимум для комфортной работы с DBF
dbfReader = new DBFReader(new FileInputStream(filename));
Map<String, Integer> fieldList = new HashMap<>();
dbfReader.setCharactersetName("cp866");
//Заполнение карты с полями, чтобы обращаться по имени поля
for (Integer i = 0; i < dbfReader.getFieldCount(); i++) {
DBFField field = dbfReader.getField(i);
@NCNecros
NCNecros / gist:fdea02c37104989c6199
Created June 2, 2015 10:09
Java 8 Distinct by property
persons.stream()
.map(Wrapper::new)
.distinct()
.map(Wrapper::unwrap)
...;
The class Wrapper might look as follows:
class Wrapper {
private final Person person;
@NCNecros
NCNecros / Main.java
Last active August 29, 2015 14:16
Convert XML to JSON
package com.company;
import org.json.JSONObject;
import org.json.XML;
import java.io.*;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import javafx.application.Application;
import javafx.scene.*;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.stage.Stage;
import javafx.util.Callback;
// demonstrates highlighting rows in a tableview based upon the data values in the rows.
public class DebtCollectionTable extends Application {
public static void main(String[] args) throws Exception { launch(args); }
@NCNecros
NCNecros / Main.java
Created December 2, 2014 18:02
get html
public static String getHtml(String url, String encoding) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(new URL(url).openStream()));
String s, html = "";
while ((s = in.readLine()) != null){
html+=s;
}
in.close();
return html;
}
@NCNecros
NCNecros / Main.java
Created December 2, 2014 18:02
RowProcessor example (org.jamel.dbf)
class FIOProcessor implements DbfRowProcessor {
public List<Human> getHumans() {
return humans;
}
public void setHumans(List<Human> humans) {
this.humans = humans;
}
List<Human> humans = new ArrayList<Human>();
@NCNecros
NCNecros / Main.java
Created December 2, 2014 18:00
Save string to file
PrintWriter writer = new PrintWriter("d:/humansFromDbf.csv", "UTF8");
for (Human human: humanList){
writer.print(human+"\n");
}
writer.close();