Skip to content

Instantly share code, notes, and snippets.

View thetutlage's full-sized avatar
🏠
Working from home

Harminder Virk thetutlage

🏠
Working from home
View GitHub Profile
@thetutlage
thetutlage / master.html
Created February 10, 2016 07:00
Master view for adonis tweedle application
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Tweedle</title>
<meta name="description" content="">
<meta name="author" content="">
<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,200,300,600,700,900' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="/style.css">
@thetutlage
thetutlage / list.html
Created February 10, 2016 08:18
Stories list view for tweedle app
{% extends '../partials/master' %}
{% block content %}
<div class="__band">
<div class="__text">
<p><b>Tweedle</b> is a place to share your tech stories in 140 characters. It is built on top of <a href="http://adonisjs.com/"> AdonisJs </a></p>
</div>
<div class="button__area">
<a href="/signup" class="__button">Join us</a>
@thetutlage
thetutlage / flatten.js
Last active January 31, 2020 17:51
Flatten an array in Javascript without recursion
'use strict'
var Benchmark = require('benchmark')
var suite = new Benchmark.Suite;
var list = [1, 2, 3, [[4]], [[[5]]], [6], [[7]]]
function flattenRecursive (list) {
var flatList = []
list.forEach(function (item) {
@thetutlage
thetutlage / scroll.js
Created December 13, 2016 17:21
Scroll to the bottom of an element with smooth animation - Pure Javascript
function scrollTo (element, duration) {
if (!element) {
return
}
var target = element.scrollHeight
target = Math.round(target)
duration = Math.round(duration)
if (duration < 0) {
return false
}
@thetutlage
thetutlage / toSentence.js
Created January 18, 2017 08:18
Function to be used with tagged ES2015 template literals
function toSentence (strings, ...values) {
const nouns = values[0] || ''
const noun = values[1] || ''
const verb = values[2] instanceof Array === true ? (nouns.length ? values[2][1] : values[2][0]) : ''
const mappedString = strings.map((char, index) => {
if (index === 0 && !nouns) {
return `${char}${noun}`
} else if (index === 1 && !nouns) {
return ''
@thetutlage
thetutlage / style.css
Last active April 23, 2021 03:19
Adonis websocket chat example style.css and html template
@import url('https://fonts.googleapis.com/css?family=Open+Sans:400,400i,600,700');
html, body {
height: 100%;
width: 100%;
}
body {
font-family: 'Open Sans', sans-serif;
font-weight: 400;
@thetutlage
thetutlage / JsonAPISerializer.js
Created April 26, 2018 18:06
Adonis JSONAPI serializer
'use strict'
const _ = use('lodash')
/**
* JSONAPI serializer for lucid models.
*
* NOTE: The implementation is not complete yet.
*
* @class JsonAPISerializer
@thetutlage
thetutlage / index.js
Created May 8, 2018 06:41
Mailgun messages.mime returning 400 with content length header
'use strict'
const nodemailer = require('nodemailer')
const got = require('got')
const FormData = require('form-data')
class MailGunTransporter {
send (mail, callback) {
const form = new FormData()
form.append('to', '<TO_EMAIL>')
@thetutlage
thetutlage / index.html
Last active June 9, 2018 04:24
Html file for adonis antl demo
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">
</head>
<body>
<nav class="navbar navbar-expand navbar-light bg-light">
<a class="navbar-brand" href="#">AdonisJs</a>
@thetutlage
thetutlage / routes.js
Created June 27, 2018 08:53
Import Adonis Database provider
const Database = use('Database')