Skip to content

Instantly share code, notes, and snippets.

View GreyTeardrop's full-sized avatar

Mykola Rybak GreyTeardrop

  • Ukraine, Kyiv
  • 21:00 (UTC +03:00)
View GitHub Profile
@mnot
mnot / RSS.py
Created October 29, 2009 12:48
RSS.py: work with RSS channels as data structures
#!/usr/bin/env python
"""
RSS.py
Classes for working with RSS channels as arbitrary data structures.
Requires Python 2.2 or newer and PyXML 0.7.1 or newer.
ChannelBase - Base class for RSS Channels.
CollectionChannel - RSS Channel modeled as a URI-per-entry
@earthgecko
earthgecko / bash.generate.random.alphanumeric.string.sh
Last active June 9, 2024 04:58
shell/bash generate random alphanumeric string
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 32 | head -n 1
@naholyr
naholyr / _service.md
Created December 13, 2012 09:39
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@agentgt
agentgt / ExampleController.java
Last active December 27, 2022 00:37
Spring Immutable Object Web Data Binding
public class ExampleController {
@RequestMapping(value = {"/blah", ""})
public @ResponseBody Map<String, Object> blah(@Valid Blah blah, BindingResult errors, ModelMap model) {
if (errors.hasErrors()) {
return ModelUtils.mapBuilder().put("status", "errors").build();
}
return ModelUtils.mapBuilder().put("status", blah.getFirst() + " " + blah.getLast()).build();
}
public static class Blah {
@w01fe
w01fe / graphviz.clj
Created February 15, 2013 06:12
Graphviz for Graphs
;; Copyright Jason Wolfe and Prismatic, 2013.
;; Licensed under the EPL, same license as Clojure
(use 'plumbing.core)
(require '[clojure.java.shell :as shell]
'[clojure.string :as str])
(import '[java.util HashSet] '[java.io File])
(defn double-quote [s] (str "\"" s "\""))
@jeroenvandijk
jeroenvandijk / simple_graph_visualization.clj
Created February 15, 2013 08:47
simple example of visualizing prismatic graphs with graphviz
(require '[plumbing.core :refer [fnk]])
(require '[plumbing.graph :as graph])
(defn calculate-deps [f]
(map (fn [parent] [parent (first f)]) (-> f second meta first second first keys)))
(defn print-dot [graph]
(println (clojure.string/join "\n"
(map (fn [r] (str "\""(first r) "\" -> \"" (second r) "\";"))
@cgrand
cgrand / comprehensions.clj
Created May 24, 2013 14:06
Comprehension framework, upon which are (re)implemented, for, doseq, reducible/foldable for and reduce-based doseq
;; I wrote this in the Eurostar on my way back from the last lambdanext.eu clojure course.
(ns comprehensions
(:refer-clojure :exclude [for doseq])
(:require [clojure.core.reducers :as r]))
;; borrowed from clojure.core
(defmacro ^{:private true} assert-args
[& pairs]
`(do (when-not ~(first pairs)
@crazed
crazed / gist:7670423
Last active September 7, 2023 22:20
getting a moto x back to stock on mac os x
  1. grab the moto-fastboot version of fastboot here

  2. grab the appropriate stock firmware here (tip: you want the one that matches your android build number in settings -> about phone)

  3. unzip this file somewhere and make it easy to run the moto-fastboot-osx64 command from step 1

  4. get your phone into fastboot mode, google it if needed but just power the phone off, hold the down volume key and power button for 3 seconds then let go, should get you there

  5. verify you are ready for flashing:

     ./moto-fastboot-osx64 devices
     -- should list a device --
    
  6. most of the time you just need to flash system and recovery images, so from your unzipped stock firmware files do this:

@staltz
staltz / introrx.md
Last active June 7, 2024 23:39
The introduction to Reactive Programming you've been missing
@bcardiff
bcardiff / list-deps.cr
Last active May 29, 2024 17:37
List binary dependencies to build a minimal docker image from scratch
unless ARGV.size > 0
puts " Missing executable file argument"
puts " Usage (in a Dockerfile)"
puts " RUN crystal run ./path/to/list-deps.cr -- ./bin/executable"
exit 1
end
executable = File.expand_path(ARGV[0])
unless File.exists?(executable)