Skip to content

Instantly share code, notes, and snippets.

@daemonfire300
daemonfire300 / email.exs
Created October 13, 2016 12:07
Simple shot at implementing an email validator for use with `Ecto.Changeset`
defmodule YourApp.Validators.Email do
use Ecto.Changeset
@mail_regex ~r/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/
# ensure that the email looks valid
def validate_email(changeset, field) do
changeset
|> validate_format(field, @mail_regex)
end
end
CREATE CONSTRAINT ON (l:Location) ASSERT l.locationid IS UNIQUE;
CREATE INDEX ON :Location(locationid);
USING PERIODIC COMMIT 5000
LOAD CSV WITH HEADERS FROM 'file:///wln_label-type.txt.csv' AS line WITH line
MERGE (location:Location {locationid: toInt(line.locationid)} )
RETURN COUNT(location);
@daemonfire300
daemonfire300 / txt_to_neoscv.py
Last active June 8, 2016 21:11
Little Helper Script to convert CSV files for neo4j
# -*- coding: utf-8 -*-
"""
Created on Wed May 25 11:26:57 2016
@author: julius
"""
import getopt, sys
defmodule ListAndRecursion do
def all?([head | tail], filter) do
if filter.(head) == true do
pall?(tail, filter, true)
else
false
end
end
defp pall?([head | tail], filter, _previous) do
if filter.(head) == true do
#include <iostream>
using namespace std;
struct Point
{
int x;
int y;
};
double inc_and_add(Point& p)
{
p.x++;
import datetime as dt
import random
def wikipedia_partition(list_set, left_end_index, right_end_index, pivot_index):
pivot_val = list_set[pivot_index]
list_set[pivot_index], list_set[right_end_index] = list_set[right_end_index], list_set[pivot_index]
temp_index = left_end_index
for i in range(left_end_index, right_end_index-1):
if pivot_val > list_set[i]:
list_set[temp_index], list_set[i] = list_set[i], list_set[temp_index]
import datetime as dt
def wikipedia_partition(list_set, left_end_index, right_end_index, pivot_index):
pivot_val = list_set[pivot_index]
list_set[pivot_index], list_set[right_end_index] = list_set[right_end_index], list_set[pivot_index]
temp_index = left_end_index
for i in range(left_end_index, right_end_index-1):
if pivot_val > list_set[i]:
list_set[temp_index], list_set[i] = list_set[i], list_set[temp_index]
temp_index += 1
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/gewünschteurl/ [OR]
RewriteCond %{HTTP_HOST} ^dieServerBasisAdresse.de$
RewriteRule ^(.*)$ http://dieServerBasisAdresse.de/diehtmldatei.html [R,L]
einfügen(p):
kind = wurzelknoten
do {
__knoten = kind
__if (p <= wert(knoten)) kind = leftChild(knoten)
__else kind = rightChild(knoten)
} while (hasChild(kind))
if (p <= wert(kind)) {
using UnityEngine;
using System.Collections;
public class targetControl : MonoBehaviour
{
public bool targetControlEnabled = true;
public bool boost = false;
public int boostCount;
// Use this for initialization
void Start ()