Skip to content

Instantly share code, notes, and snippets.

🍹
Being an Elixir alchemist

Maximilian Stroh Anonyfox

🍹
Being an Elixir alchemist
Block or report user

Report or block Anonyfox

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Anonyfox
Anonyfox / example_controller_test.exs
Created Oct 22, 2015
Pattern how to test a controller that needs a logged-in user in phoenix. Follows the example code written in https://pragprog.com/book/phoenix/programming-phoenix
View example_controller_test.exs
defmodule N3ws.ChannelControllerTest do
import Plug.Conn, only: [assign: 3]
@valid_attrs %{name: "some content"}
@invalid_attrs %{}
@user_attrs %{
email: "some content",
name: "some content",
password_virtual: "some content"
}
View microsites-compiler.ex
defmodule Microsites.Compile do
import File
def directory(folder \\ "elixir-lang.info") do
folder
|> reset_destination_folder
|> copy_assets
|> create_metadata
|> read_content_files
|> create_html_files
@Anonyfox
Anonyfox / The Technical Interview Cheat Sheet.md
Last active Aug 26, 2015 — forked from TSiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.
View The Technical Interview Cheat Sheet.md

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
View tinytest.api
test.isFalse(v, msg)
test.isTrue(v, msg)
test.equal(actual, expected, message, not)
test.length(obj, len)
test.include(s, v)
test.isNaN(v, msg)
test.isUndefined(v, msg)
test.isNotNull
test.isNull
test.throws(func)
@Anonyfox
Anonyfox / gist:32f4b599008b97500466
Last active Apr 29, 2018
nodejs file server example
View gist:32f4b599008b97500466

Influenza, the minimalistic blogging engine.

Based on Node.js/Express.js and flat markdown files. This is the main (and only) code file, containing all the logic and code, and is written in literate Coffeescript. The Idea is that you just put your articles as markdown files (*.md) in the /posts folder, and Influenza takes care of all the other stuff.

Only the following npm modules are used:

express   = require "express"
exphbs    = require "express-handlebars"
View meteor.cheatsheet.coffee
METEOR CORE:
Anywhere: Meteor.isClient
Anywhere: Meteor.isServer
Anywhere: Meteor.startup(func)
Anywhere: Meteor.absoluteUrl([path], [options])
Anywhere: Meteor.settings
Anywhere: Meteor.release
View encrypt_decrypt.js
function encrypt(text){
var cipher = crypto.createCipher('aes-256-cbc','d6F3Efeq')
var crypted = cipher.update(text,'utf8','hex')
crypted += cipher.final('hex');
return crypted;
}
function decrypt(text){
var decipher = crypto.createDecipher('aes-256-cbc','d6F3Efeq')
var dec = decipher.update(text,'hex','utf8')
View bootstrap.flatten.css
/* Flatten das boostrap */
.well, .navbar-inner, .popover, .btn, .tooltip, input, select, textarea, pre, .progress, .modal, .add-on, .alert, .table-bordered, .nav>.active>a, .dropdown-menu, .tooltip-inner, .badge, .label, .img-polaroid {
-moz-box-shadow: none !important;
-webkit-box-shadow: none !important;
box-shadow: none !important;
-webkit-border-radius: 0px !important;
-moz-border-radius: 0px !important;
border-radius: 0px !important;
border-collapse: collapse !important;
background-image: none !important;
View unicorn.sublime-snippet
<snippet>
<content><![CDATA[
console.log(" /");
console.log(" .7");
console.log(" \\\ , //");
console.log(" |\\\.--._/|//");
console.log(" /\\\ ) ) ).'/");
console.log(" /( \\\ // /");
console.log(" /( J`((_/ \\\");
console.log(" / ) | _\\\ /");
View coffee_script_tricks.coffee
# These are my notes from the PragProg book on CoffeeScript of things that either
# aren't in the main CS language reference or I didn't pick them up there. I wrote
# them down before I forgot, and put it here for others but mainly as a reference for
# myself.
# assign arguments in constructor to properties of the same name:
class Thingie
constructor: (@name, @url) ->
# is the same as:
You can’t perform that action at this time.