Skip to content

Instantly share code, notes, and snippets.

Avatar
Creating Black holes.

Pankaj Doharey metacritical

Creating Black holes.
View GitHub Profile
@metacritical
metacritical / random_sentence.rb
Last active Jul 12, 2021
Create a text file with random sentences of a specific size in bytes.
View random_sentence.rb
#Create a random sentence file of spcified size.
#Usage : ruby sentence.rb 100000000 #In bytes.
DICT="/usr/share/dict/words"
words = File.read(DICT).split(' ')
maxsize = ARGV[0].to_i || 10000000000
current_size = 0
f = File.open('testfile.txt', 'a')
char = %w(| / - \\).cycle
while current_size < maxsize
@metacritical
metacritical / router.clj
Created May 27, 2021 — forked from borkdude/router.clj
Small ring router using core.mach in babashka
View router.clj
(require '[clojure.core.match :refer [match]]
'[clojure.string :as str]
'[hiccup2.core :refer [html]]
'[org.httpkit.server :as server])
(defn router [req]
(let [paths (vec (rest (str/split (:uri req) #"/")))]
(match [(:request-method req) paths]
[:get ["users" id]] {:body (str (html [:div id]))}
:else {:body (str (html [:html "Welcome!"]))})))
View *nokogiri-commandline-ref.txt
require 'nokogiri'
require 'open-uri'
# Get a Nokogiri::HTML:Document for the page we're interested in...
doc = Nokogiri::HTML(open('http://www.google.com/search?q=tenderlove'))
# Do funky things with it using Nokogiri::XML::Node methods...
####
View react-es6-flow-emacs-configuration.md

Configuring Emacs for react, es6, and flow

For a while, JSX and new es6 syntax had flaky support in emacs, but there's been huge work on a lot of packages. Using emacs for JavaScript with React, ES6, and Flow (or Typescript, etc) is really easy and powerful in Emacs these days.

This is how you can work on modern web development projects with full support for tooling like JSX, Flow types, live eslint errors, automatic prettier.js formatting, and more.

Set up web-mode

web-mode provides most of the underlying functionality, so a huge shout-out to the maintainer(s) there.

@metacritical
metacritical / postgres-brew.md
Last active Oct 31, 2020 — forked from ibraheem4/postgres-brew.md
Installing Postgres via Brew (OSX)
View postgres-brew.md

Installing Postgres via Brew (Read From below for issues)

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
@metacritical
metacritical / cprint.clj
Created Aug 4, 2019 — forked from kocubinski/cprint.clj
ClojureCLR println with colors in Windows cmd.exe
View cprint.clj
(assembly-load "ClojureClrEx")
(ns clync.core
(:use [clojure.clr.pinvoke :only [dllimports]]))
(dllimports
"Kernel32.dll"
(GetStdHandle IntPtr [Int32])
(SetConsoleTextAttribute Boolean [IntPtr UInt32]))
@metacritical
metacritical / handle-escape-opentk.clj
Last active Jul 30, 2019
Inherit GameWindow using proxy and Override OnUpdateFrame method.
View handle-escape-opentk.clj
(ns core
(:gen-class))
(assembly-load-from "./extern/OpenTK/lib/net20/OpenTK.dll")
(import [System]
[System.IO]
[System.Console]
[System.Drawing]
[OpenTK]
@metacritical
metacritical / core-import.clj
Last active Jul 29, 2019
Creating The Game window.
View core-import.clj
(ns core
(:gen-class))
(assembly-load-from "./extern/OpenTK/lib/net20/OpenTK.dll")
(defn -main[]
(Console/WriteLine "Starting OpenTK Window."))
@metacritical
metacritical / core.clj
Last active Jul 29, 2019
Clojure-CLR Hi World!
View core.clj
(ns core
(:gen-class))
(import [System])
(defn -main[]
(System.Console/WriteLine "Hi World"))
@metacritical
metacritical / build.sh
Last active Jul 30, 2019
Clojure-CLR build script for hi world.
View build.sh
#!/usr/local/bin/bash
runtime="mono"
cljcomp=$CLOJURE_LOAD_PATH/Clojure.Compile.exe
compile(){
CLOJURE_COMPILE_PATH=build/ $runtime $cljcomp core
}
link_dlls(){