Skip to content

Instantly share code, notes, and snippets.

View gmx's full-sized avatar

Graham Max gmx

  • Rangoon
View GitHub Profile
const links = Array.from(document.querySelectorAll("tr.athing")).map((elem) => {
const { href, innerText } = elem.querySelector(".titleline > a")
const links = Array.from(elem.nextElementSibling.querySelectorAll("a"));
const commentLink = links[links.length - 1];
return {href, innerText, comment: commentLink.href}
});
@gmx
gmx / room_rate.js
Created October 1, 2019 13:56
mapping 2 arrays
const RoomRates = ({ rooms }: { rooms: any }) => {
const formatDate = (dateStr:string) => moment(dateStr).format('DD/MM/YYYY')
const {formValue} = useContext( LibContext )
console.log('form value', formValue)
const groupedRooms = rooms.map((room:any) => {
// generate occupancy list first
const [occupancyList, _] = room.rates.reduce(([ result, index, groupIdx ], _) => {
// Instruction
//
// Go to facebook "sent friend requests page"
// https://www.facebook.com/friends/requests/?fcref=jwl&outgoing=1
// Then run the script below in your browser console
// You might need to click "Cancel Request" only in the very first time
// and the rest will be handled by this stupid script.
// Unfriend useless crush and have fun :P
// a lot more to improve :P
@gmx
gmx / BaseModel.php
Created December 16, 2017 12:36 — forked from JeffreyWay/BaseModel.php
To make for clean and readable tests, do your mocking in a base model that your Eloquent models extend.
<?php
class BaseModel extends Eloquent {
public static function shouldReceive()
{
$repo = get_called_class() . 'RepositoryInterface';
$mock = Mockery::mock($repo);
App::instance($repo, $mock);
Expression
= value:Line* {
return value;
}
Line
= entity:[a-zA-Z_]+ _ "[" params:(Param)+ "]" _ {
return {
entity: entity.join(""),
params: params
@gmx
gmx / README.md
Created February 13, 2017 04:09 — forked from rrag/README.md
An attempt at FRP using Ramda.js and Bacon.js
function odd( array ) {
return _.filter( array, function( v, k ){ return k % 2 !== 0; });
}
function even( array ) {
return _.filter( array, function( v, k ){ return k % 2 === 0; });
}
var makeEqualLength = function( arrays ) {
/**
* creating an array iterate all the days between startDate and endDate
* depends on MomentJS
*/
function populateDateArray( startDate, endDate ) {
var mStartDate = moment( startDate, 'YYYY-MM-DD' );
var mEndDate = moment( endDate, 'YYYY-MM-DD' );
var days = []; var curDate = mStartDate;
for ( ; curDate.format('YYYY-MM-DD') != endDate ; curDate = mStartDate.add('days', 1)) {
@gmx
gmx / gist:7263287
Created November 1, 2013 09:59
SCALA Learning Curve
ML Languages
http://smlnj.org
Programming in ML