Skip to content

Instantly share code, notes, and snippets.

View alebon's full-sized avatar

Alexej Bondarenko alebon

View GitHub Profile
@alebon
alebon / shell.nix
Created February 20, 2021 09:34
Ethminer shell
{ pkgs ? import <nixpkgs> { } }:
let
ethMinerScript = pkgs.writeScriptBin "start" ''
ethminer --farm-recheck 200 --cuda --pool stratum1+tcp://<ETH_ADDRESS>.<ETH_MINER_TAG>@eu1.ethermine.org:4444
'';
in
pkgs.mkShell {
buildInputs = with pkgs; [
ethminer
{ pkgs ? import <nixpkgs> { } }:
let
replScript = pkgs.writeScriptBin "repl" ''
ghci
'';
in
pkgs.mkShell {
buildInputs = [
pkgs.haskellPackages.ghc
@alebon
alebon / gist:a95a3613dbf0a7cb608d0e9207ec215e
Created January 20, 2021 19:19
Nixos Partitioning for vServer on Netcup.de
parted /dev/sda -- mklabel msdos
parted /dev/sda -- mkpart primary 1MiB -4GiB
parted /dev/sda -- mkpart primary linux-swap -4GiB 100%
{ mkDerivation, aeson, base, bytestring, http-types, lucid, mtl
, servant, servant-docs, servant-server, stdenv, text, wai
, wai-extra
}:
mkDerivation {
pname = "my-app";
version = "1.0.0.0";
src = ./.;
isLibrary = true;
isExecutable = true;
@alebon
alebon / release.nix
Created January 11, 2021 12:20
Nix Docker Image creation
let
config = {
packageOverrides = pkgs: rec {
haskellPackages = pkgs.haskellPackages.override {
overrides = haskellPackagesNew: haskellPackagesOld: rec {
myApp =
haskellPackagesNew.callCabal2nix "my-app" (./.) { };
};
};
};
object JsFunctions {
// Some more code here, using the buildServiceFunctions method
def buildServerFunctions(name: String, funcs: List[RoundTripInfo], session: Box[LiftSession]): JsCmd = {
JsRaw("""lift_serverFunctions().apply('%s', %s)"""
.format(name, session.getOrElse(throw new Exception("Session required")).buildRoundtrip(funcs).toJsCmd).stripMargin).cmd
}
class OrientIndexHandler(graph: OrientGraph) extends IndexHandler {
override def createUniqueIndexField[ModelType, FieldType](field: Field[ModelType, FieldType], label: String): Unit = {
val keyName = field.name
val indexName = s"idx${label}_$keyName"
val vertexType = graph.getVertexType(label)
if (!vertexType.existsProperty(keyName)) {
field match {
package demo.js
import net.liftweb.http.js.JsCmd
object JsCommands30 {
/**
* JsSchedule the execution of the JsCmd using setTimeout()
* @param what the code to execute
*/
@alebon
alebon / SamspleControllerBackend.scala
Created September 12, 2013 08:34
AngularJS with Lift 2.5
class SampleControllerBackend extends StatefulSnippet with Logger {
protected lazy val controllerId = Helpers.nextFuncName
def dispatch = {
case "serverFunctions" => serverFunctions _
case "allowModule" => allowModule _
}
def allowModule(xhtml: NodeSeq): NodeSeq = {
@alebon
alebon / MySpec.scala
Created August 16, 2012 03:34
OrientDB Spec
class MySpec extends Specification {
"OrientGraph Repository" should {
"create 15 relationships properly" in {
val db = OGraphDatabasePool.global()
.acquire("remote:127.0.0.1/db", "admin", "admin")
val clazz = db.getVertexType("TARGET_VERTEX")
if (clazz == null) {