Skip to content

Instantly share code, notes, and snippets.

#include <iostream>
#include <cstdio>
#include <cmath>
const double EPS = 0.000000000000000000000000000000000000001;
double f(double x){
return x*2+5;
}
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
const double EPS = 0.000000001;
double f(double x){
return 2*x+2;
}
@Hajto
Hajto / Debugging phonegap camera
Created February 21, 2015 12:01
Debuging camera
var cameraSettings = {
quality: 50,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.CAMERA
};
var gallerySettings = {
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
quality: 50,
destinationType: Camera.DestinationType.FILE_URI
};
java.lang.NullPointerException
at com.haito.opbmaddon.tileEntity.TEPotionStation.writeSyncableDataToNBT(TEPotionStation.java:29) ~[TEPotionStation.class:?]
at com.haito.opbmaddon.tileEntity.TEPotionStation.writeToNBT(TEPotionStation.java:48) ~[TEPotionStation.class:?]
at net.minecraft.world.chunk.storage.AnvilChunkLoader.writeChunkToNBT(AnvilChunkLoader.java:395) [AnvilChunkLoader.class:?]
at net.minecraft.world.chunk.storage.AnvilChunkLoader.saveChunk(AnvilChunkLoader.java:204) [AnvilChunkLoader.class:?]
at net.minecraft.world.gen.ChunkProviderServer.safeSaveChunk(ChunkProviderServer.java:287) [ChunkProviderServer.class:?]
at net.minecraft.world.gen.ChunkProviderServer.saveChunks(ChunkProviderServer.java:340) [ChunkProviderServer.class:?]
at net.minecraft.world.WorldServer.saveAllChunks(WorldServer.java:862) [WorldServer.class:?]
at net.minecraft.server.MinecraftServer.saveAllWorlds(MinecraftServer.java:370) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.stopServer(MinecraftServer
@Hajto
Hajto / Scrapper
Created May 23, 2015 09:45
Scala Scrapper
import model.FuneralSchedule
import play.api.libs.json.Json
import scala.io.Source
var date = "2015-05-05"
val source = Source.fromURL("http://zck.krakow.pl/?pageId=16&date=" + date).mkString
val regex = "(?s)<table>.+?(Cmentarz.+?)<.+?</table>".r
var thing: List[FuneralSchedule] = List()
var jsonFeed: List[Funeral] = List()
val regMatcher = "("
@Hajto
Hajto / controls
Last active August 29, 2015 14:22
var lightsControls = {
red: {
value: 0,
name: "R",
color: "#FF0000",
min: 0,
max: 255
},
green: {
value: 0,
selectMaps($()).map { elem =>
elem.map { jsValue =>
jsValue.validate[Level].get
}: List[Level]
}.collect {
case (list: List[Level]) => Ok(views.html.levelChooser(list))
}
package objsets
import common._
import TweetReader._
/**
* A class to represent tweets.
*/
class Tweet(val user: String, val text: String, val retweets: Int) {
override def toString: String =
@Hajto
Hajto / Andrzej.ex
Last active September 11, 2015 19:35
Andrzej's task
defmodule Andrzej do
def getData(s), do: String.replace(IO.gets(s),"\n","")
def gIndex(list,elem), do: Enum.find_index(list, fn x -> x == elem end)
def testCombinator (listS) do
x = [" pierwsza forma "," druga forma "," trzecia forma ", " polski "]
listP = List.zip([x,listS])
Enum.map(listS, fn a -> Enum.map(listP,
fn {b,c} ->
unless gIndex(listS,a) == gIndex(x,b) do
getData(a <> "=>" <> b) == c
@Hajto
Hajto / deserialization.scala
Created September 12, 2015 14:21
Trying to resolve problem
package model
import play.api.data.Form
import play.api.libs.json.Json
import model.SkillFormats.skillRecordFormat
import play.api.data._
import play.api.data.Forms._
object UserFormats {
implicit val userForm = Form(