Skip to content

Instantly share code, notes, and snippets.

View varemenos's full-sized avatar

Adonis Kakoulidis varemenos

View GitHub Profile
@xjamundx
xjamundx / blog-webpack-2.md
Last active April 21, 2024 16:20
From Require.js to Webpack - Part 2 (the how)

This is the follow up to a post I wrote recently called From Require.js to Webpack - Party 1 (the why) which was published in my personal blog.

In that post I talked about 3 main reasons for moving from require.js to webpack:

  1. Common JS support
  2. NPM support
  3. a healthy loader/plugin ecosystem.

Here I'll instead talk about some of the technical challenges that we faced during the migration. Despite the clear benefits in developer experience (DX) the setup was fairly difficult and I'd like to cover some of the challanges we faced to make the transition a bit easier.

These are the configuration and package-syncing files I'm using for my setup of the Atom Editor
@nolanlawson
nolanlawson / protips.js
Last active February 4, 2024 18:06
Promise protips - stuff I wish I had known when I started with Promises
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");
@staltz
staltz / introrx.md
Last active May 7, 2024 09:38
The introduction to Reactive Programming you've been missing
@varemenos
varemenos / ArrayMoveFunction.js
Created April 2, 2014 12:35
Function to move an Array item to another position of that Array
var t = [ 'a', 'b', 'c', 'd', 'e'];
Array.prototype.move = function (source, destination) {
// if source and destination are the same
if (source === destination) {
// then there is no need to move
return;
}
// if the source is smaller than 0 or the destination is larger than the size of the array
if (source < 0 || source > this.length - 1 || destination > this.length - 1) {
@varemenos
varemenos / checkCalc.js
Last active December 29, 2015 12:19
Check if calc() is supported by your browser
// returns true if your browser supports calc()
myapp.checkCalc = function (prefix = '') {
var el = document.createElement('div');
el.style.cssText = prefix + 'width: calc(1px);';
return !!el.style.length;
};
// returns true if your browser supports any version of calc(), prefixed or not
myapp.checkAllCalc = function (prefix = '') {
return myapp.checkCalc('-webkit-') || myapp.checkCalc('-moz-') || myapp.checkCalc();
@varemenos
varemenos / powerquake.ahk
Created August 27, 2013 05:24
PowerShell - QuakeStyle (now supports posh~git as well)
F12::
DetectHiddenWindows, on
If WinExist("posh~git") OR WinExist("Windows PowerShell")
{
If WinActive("posh~git") OR WinActive("Windows PowerShell")
{
WinHide
if(temptitle="")
WinActivate ahk_class Shell_TrayWnd
@varemenos
varemenos / Microsoft.PowerShell_profile.ps1
Created August 23, 2013 05:04
A profile script that generates a prompt similar to this: AdonisK@home-pc: C:\Users\AdonisK$_
# Clear screen
cls
# Get user
$USER = $PWD.toString()
$USER = $USER.Remove(0, 9)
# Get hostname
$HOSTNAME = HOSTNAME.exe
@varemenos
varemenos / oop.php
Created May 16, 2013 00:24
PHP - Basic OOP
<?
class entry{
private $id = -1; // required
private $title = ""; // required
private $author = -1; // required, author ID
private $excerpt = ""; // either turn title into excerpt or manually enter one
private $date = ""; // required
// #TODO
// post type interface?
@varemenos
varemenos / 1.objectCreation.js
Created May 15, 2013 15:45
JavaScript - The basics of Object Oriented Programming
// Class creation
function Vehicle(p) {
this.brand = p.brand || "";
this.model = p.model || "";
this.wheels = p.wheels || 0;
}
// Main class' methods
Vehicle.prototype.getBrand = function () {
return this.brand;