Skip to content

Instantly share code, notes, and snippets.

View typehorror's full-sized avatar
Living life

Type Horror typehorror

Living life
View GitHub Profile
@typehorror
typehorror / index.html
Created August 15, 2020 22:26
Grid Work
<html>
<head>
<style>
html {
font-family: sans-serif;
}
code {
background-color: #333333;
color: #dddddd;
padding: 4px 8px;
@typehorror
typehorror / fromModule.js
Last active July 9, 2020 18:19
Create a feature folder from an existing feature folder
#!/usr/bin/env node
// this is to use when you duplicate a module.
// For example, lets say you have all the crud basic feature for "user"
// and you would like to seed the feature "product" with it.
// You'll have to copy "user" into "product", search and replace every instance
// of user and replace them into "product"...
// and "User" into "Product"...
// and "USER" into "PRODUCT"...
// and rename all the files.. include XXX_USER.foo into XXX_PRODUCT.foo
//
@typehorror
typehorror / devices.html
Last active May 2, 2020 01:00
Device test webpage - a la sizzy
<!DOCTYPE html>
<head>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"
/>
<style>
body {
background-color: aliceblue;
}
@typehorror
typehorror / multiples.js
Created February 2, 2020 17:54
Simpler solution of the iterative method
function sumMultiples(n, mul){
var sum=0;
for (var i = 0 ; i < n ; i = mul + i) {
sum += i;
}
return sum;
}
console.log(sumMultiples(1000, 5) + sumMultiples(1000, 3) - sumMultiples(1000, 15));
import { Component } from "react";
import { connect } from "react-redux";
import { getTicket, getAssignedTickets } from "../../actions";
import { getJWToken } from "../../middleware/api";
class Socket extends Component {
getWebsocketServerLocation() {
const host = window.document.location.host.replace(/:.*/, "");
return "ws://" + host + ":8010";
@typehorror
typehorror / description.md
Last active June 27, 2017 19:36
Lambda function name error

Hey guys,

I've suddenly (around 11:30am Pacific) been getting this error on every single one of my API gateway -> lambda calls. I'm using Terraform and Apex to manage my deployment. This happened after my latest deployment. No changes to my method names occurred. Also, I've tested the ARN versus the RegExp your error mentions and it actually matches:

Error

{"message": "1 validation error detected: Value \'arn:aws:lambda:us-east-1:347978430301:function:arn:aws:lambda:us-east-1:347978430301:function:experiment_stamps\' at \'functionName\' failed to satisfy constraint: Member must satisfy regular expression pattern: (arn:(aws|aws-us-gov):lambda:)?([a-z]{2}(-gov)?-[a-z]+-\\d{1}:)?(\\d{12}:)?(function:)?([a-zA-Z0-9-_\\.]+)(:(\\$LATEST|[a-zA-Z0-9-_]+))?"}
Tue Jun 27 19:12:08 UTC 2017 : Endpoint response body before transformations: {"message":"1 validation error detected: Value 'arn:aws:lambda:us-east-1:347978430301:function:arn:aws:lambda:us-east-1:347978430301:function:experiment_notifications' at 'fu
function CSS_compute_middleware(css, next) {
if(this.foo === 'bar'){
css.padding = 0;
}
return next(css)
}
function CSS_async_compute_middleware(css, next) {
if(this.bar === 'foo'){
@typehorror
typehorror / elevators.py
Last active July 28, 2016 17:11
Optimize the elevator controller
"""
Elevator Exercise.
Edit the ElevatorController implementation, focusing on
the ElevatorController.call(Passenger) method.
Run the elevator script try to increase your score.
python elevators.py
> score: 51
@typehorror
typehorror / README.md
Last active December 11, 2016 15:16
Celery task bug in a SQLAlchemy event

Celery Bug

When running a celery task, in a SQLAlchemy event, in a unit-test the connection get destroyed somehow.

I attached the requirement to reproduce the bug:

git clone https://gist.github.com/5762792fc1d628843697.git
cd 5762792fc1d628843697
virtualenv venv

. venv/bin/activate

@typehorror
typehorror / detector.md
Last active February 19, 2024 03:06
Detecting Similar News

Detecting Similar News

The following gist is an extract of the article Detecting Similar News. It exploit data retrieve by a crawler and detect similar article across different domains

Usage

Start by running the crawler to retrieve the data. Crawler takes about 50 minutes to retrieve all the data the first time.

$ python run.py

retrieving url... [techcrunch.com] /