Skip to content

Instantly share code, notes, and snippets.

View aberba's full-sized avatar

Lawrence Aberba aberba

View GitHub Profile
import { PRIMARY, PRIMARY_LIGHT, IRON_GREY } from '@styles/variables/colors'
import React, { useEffect, useRef, useState } from 'react'
import styled from 'styled-components'
const Slider = styled.div`
position: relative;
margin: 16px auto;
width: calc(100% - 12px);
height: 8px;
background: ${PRIMARY_LIGHT};
@suberb
suberb / elementaryos.md
Last active December 25, 2023 19:14
elementaryOS | Things To Do After Installing Elementary OS Loki [Best OS For Switching From Windows & Mac]

FIRST THING FIRST


  • Update OS
sudo apt-get update && sudo apt-get upgrade

@Philip-Scott
Philip-Scott / VideoPlayer.vala
Last active October 22, 2020 18:20
ClutterGStreamer & Gtk video player widget in Vala
/*-
* Copyright (c) 2017
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@vlucas
vlucas / encryption.js
Last active April 2, 2024 14:26
Stronger Encryption and Decryption in Node.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv);
@newyankeecodeshop
newyankeecodeshop / ServingES6.md
Last active June 19, 2021 07:36
Serving ES6 to modern browsers

Background

Recently I noticed that Safari 10 for Mac/iOS had achieved 100% support for ES6. With that in mind, I began to look at the browser landscape and see how thorough the support in the other browsers. Also, how does that compare to Babel and its core-js runtime. According to an ES6 compatability table, Chrome, Firefox, and IE Edge have all surpassed what the Babel transpiler can generate in conjunction with runtime polyfills. The Babel/core-js combination achieves 71% support for ES6, which is quite a bit lower than the latest browsers provide.

It made me ask the question, "Do we need to run the babel es2015 preset anymore?", at least if our target audience is using Chrome, Firefox, or Safari.

It's clear that, for now, we can't create a site or application that only serves ES6. That will exclude users of Internet Explorer and various older browsers running on older iOS and Android devices. For example, Safari on iOS 9 has pretty mediocre ES6 support.

@acdlite
acdlite / app.js
Last active January 20, 2023 08:23
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {
@rauschma
rauschma / about-proposal.md
Last active October 6, 2023 18:30
Enum proposal

Advantages compared to using symbols as enum values:

  • Enum values are much more customizable. For example, one can have custom prototype and/or instance methods.
  • Enum values get two custom properties:
    • name provides direct access to the name of an enum value.
    • ordinal holds a number, the position of the enum value. Useful for some applications.
  • One can use instanceof to test whether a value is an element of an enum.
  • One occasionally requested feature for enums is that enum values be numbers (e.g. for flags) or strings (e.g. to compare with values in HTTP headers). That can be achieved by making those values properties of enum values. For an example, see enum Mode, below.

Static properties of enums:

@jvenezia
jvenezia / heroku_application_migration.md
Last active August 16, 2019 03:45
Migrating an Heroku Application to another

Migrating an Heroku Application to another

The usecase here is to migrate an Heroku Application to Heroku Europe, and minimise downtime.

The heroku documentation on this subject is quite complete.
It is recommanded to read it if you are planning a migration.
https://devcenter.heroku.com/articles/app-migration

Process

In this guide, sourceapp is the original (source) app and targetapp is the migrated (target) app.

@pasupulaphani
pasupulaphani / after_res_hooks.js
Last active March 20, 2024 22:23
Mongoose connection best practices
var db = mongoose.connect('mongodb://localhost:27017/DB');
// In middleware
app.use(function (req, res, next) {
// action after response
var afterResponse = function() {
logger.info({req: req}, "End request");
// any other clean ups
@fecub
fecub / Game.java
Last active August 27, 2020 13:44
GameDev - Jumping Algorithm
/*
Initialize the variables
--------------------------
private int jumpWidth = 0;
private boolean jumpStatus = false;
private int gravity = 2;
private int jumpPower = 5;
private boolean startJump = false;
*/