Skip to content

Instantly share code, notes, and snippets.

View waptik's full-sized avatar
💻
Learning JavaScript and ReactJS...

Stephane Mensah waptik

💻
Learning JavaScript and ReactJS...
View GitHub Profile
@waptik
waptik / js_string_drills.txt
Created April 8, 2018 06:52
Links to JS String Drills
Wiseperson Generator: https://jsbin.com/niwufic/edit?js,console,output
Shouter : https://jsbin.com/tuwexoc/edit?js,console,output
Text normalizer: https://jsbin.com/likavis/edit?js,console,output
@waptik
waptik / js_number_drills.txt
Created April 8, 2018 07:18
Links to Number Drills
Area of a Rectangle: https://jsbin.com/edit?js,console
Temperature Conversion: http://jsbin.com/xuvaqor/edit?js,console
Is devisible: http://jsbin.com/baniyi/edit?js,console
@waptik
waptik / JsonMiddleware.php
Created July 23, 2018 01:24 — forked from meSingh/JsonMiddleware.php
If you are using laravel as api only, you might want to return JSON on every request, even on errors/exceptions. The easiest way to do so is using this middleware globally.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class JsonMiddleware
{
public function handle(Request $request, Closure $next)
https://stackoverflow.com/questions/19961387/trying-to-get-a-list-of-collections-from-mongoose [list all collections]
https://stackoverflow.com/questions/17035297/getting-schema-attributes-from-mongoose-model [schema paths]
https://github.com/buunguyen/mongoose-migrate
https://github.com/balmasi/migrate-mongoose
https://github.com/gonza-lito/migrate-mongoose
https://github.com/megahertz/mongoomig
https://github.com/acarl005/mongoose-cli (with timestamp)
https://github.com/SamVerschueren/mongoose-seeder/ [seeder]
https://github.com/seanemmer/mongoose-seed
@waptik
waptik / models_index.js
Created June 21, 2019 02:51
Mongoose import models the Sequelize way
'use strict';
const fs = require('fs');
const path = require('path');
const Mongoose = require('mongoose');
const basename = path.basename(__filename);
const env = process.env.NODE_ENV || 'development';
const config = require(__dirname + '/../config/config.json')[env];
if (config.database.url) {
@waptik
waptik / models_index.js
Created June 21, 2019 03:10
Mongoose models import, my way
'use strict';
const fs = require('fs');
const path = require('path');
const Mongoose = require('mongoose');
const basename = path.basename(__filename);
const env = process.env.NODE_ENV || 'development';
const config = require(__dirname + '/../config/config.json')[env];
if (config.database.url) {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Mini App</title>
<style>
body {
margin: 0;
@waptik
waptik / HeavenManga.kt
Created August 3, 2019 20:09
portion of code for HeavenManga extension(Tachiyomi)
...
import org.jsoup.Jsoup
....
class HeavenManga : ParsedHttpSource() {
...
override val baseUrl = "http://heavenmanga.com"
@waptik
waptik / luxon-zeit-ms_time-convert.js
Last active October 27, 2019 02:48
This uses zeit's ms to convert relation time (eg. 4 days ago) to convert to to preferred time format `10/23/19` using momentjs' luxon
var { DateTime } = require("luxon")
var ms = require("ms")
/**
* this takes a relative time `xxx xxx ago` and returns `xxx xxx`
**/
function stripAgo(date) {
const trime = date.split(" ");
// console.log("trime ==> ", trime);
return trime[2] === "ago" ? `${trime[0]} ${trime[1]}` : date;