Skip to content

Instantly share code, notes, and snippets.

View pavelsr's full-sized avatar
🏠
Working from home

Pavel Serikov pavelsr

🏠
Working from home
View GitHub Profile
@pavelsr
pavelsr / jstree
Created May 13, 2014 14:33
Fucking json in jstree
$(document).ready(function() {
$('#jstree2').jstree({
'core' : {
'data' : {
'url' : function (node) {
console.log("url");
return 'api.json';
},
'data' : function (node) {
console.log(node);
@pavelsr
pavelsr / correct_id_placement
Last active August 29, 2015 14:02
Correct id in layout
<LinearLayout
android:id="@+id/test_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
Button myButton = (Button) findViewById(R.id.my_button)
import com.jjoe64.graphview.BarGraphView;
import com.jjoe64.graphview.GraphView;
import com.jjoe64.graphview.GraphView.GraphViewData;
import com.jjoe64.graphview.GraphViewSeries;
import com.jjoe64.graphview.LineGraphView;
06-09 00:29:39.954: D/AndroidRuntime(14047): Shutting down VM
06-09 00:29:39.954: W/dalvikvm(14047): threadid=1: thread exiting with uncaught exception (group=0x41c52d40)
06-09 00:29:39.959: E/AndroidRuntime(14047): FATAL EXCEPTION: main
06-09 00:29:39.959: E/AndroidRuntime(14047): Process: com.example.graphviewtest, PID: 14047
06-09 00:29:39.959: E/AndroidRuntime(14047): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.graphviewtest/com.example.graphviewtest.MainActivity}: java.lang.NullPointerException
06-09 00:29:39.959: E/AndroidRuntime(14047): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209)
06-09 00:29:39.959: E/AndroidRuntime(14047): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269)
06-09 00:29:39.959: E/AndroidRuntime(14047): at android.app.ActivityThread.access$800(ActivityThread.java:139)
06-09 00:29:39.959: E/AndroidRuntime(14047): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
06-09 0
package com.example.graphviewtest;
import com.jjoe64.graphview.GraphViewSeries;
import com.jjoe64.graphview.GraphView;
import com.jjoe64.graphview.GraphView.GraphViewData;
import com.jjoe64.graphview.LineGraphView;
import android.support.v7.app.ActionBarActivity;
import android.support.v4.app.Fragment;
import android.os.Bundle;
String displayText = "";
try {
InputStream fileStream = getResources().openRawResource(R.raw.samples_100hz);
int fileLen = fileStream.available();
// Read the entire resource into a local byte buffer.
byte[] fileBuffer = new byte[fileLen];
fileStream.read(fileBuffer);
fileStream.close();
displayText = new String(fileBuffer);
} catch (IOException e) {
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
//Пример вызова
//Signal.derivative(asd,adsd);
public class Signal{
public static double [] derivative(double[] arr, Integer f){
double [] ret_array= new double[arr.size()-1];
for(i=0;i<arr.size()-1;i++){
ret_array[i]=arr[i+1]-arr[i]*f;
}
@pavelsr
pavelsr / smart_compare
Created December 26, 2014 09:22
Smart compare cells and print result in a human-friendly format
//пример вызова - smart_compare(E1,"B43:B52");
// пример использования https://docs.google.com/spreadsheets/d/1m9P5lOhfbEmzyXWaEZkYRya6Ni_E9bF47iGY1PneXU0/edit#gid=0
// документация API Google Spreadsheets
// https://developers.google.com/apps-script/reference/spreadsheet/sheet
// https://developers.google.com/apps-script/reference/spreadsheet/range
function smart_compare (cell, range) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var target_range = sheet.getRange(range); // sheet.getRange("A1:D10") возвращает объект Class Range