Skip to content

Instantly share code, notes, and snippets.

View somogyibence's full-sized avatar
💭
🌶

Bence Somogyi somogyibence

💭
🌶
View GitHub Profile
@somogyibence
somogyibence / mount.js
Last active December 20, 2021 21:10
Wait for a Vue component to mount
/*
Use this with co-mocha (https://www.npmjs.com/package/co-mocha)
and transform-async-to-generator (https://www.npmjs.com/package/babel-plugin-transform-async-to-generator)
for testing purposes.
Example:
import SomeComponent from './SomeComponent'
import mount from './mount'
describe('SomeComponent', () => {
let component
import UIKit
import Foundation
class TriangeView: UIView {
init(frame: CGRect, backgroundColor: UIColor) {
super.init(frame: frame)
self.backgroundColor = backgroundColor
}
required init?(coder aDecoder: NSCoder) {

Maintanable / Readable PHP Code guidelines

1. Strings:

Always use singlequote if you do not need a template string.

<?php
    // this will be compiled 'as is'
    $thisIsALiteralString = 'Such Doge!';
?>
@somogyibence
somogyibence / some-class.php
Last active June 24, 2016 09:30
Importing constants in PHP [5.6+]
<?php
namespace app;
use const app\config\SOME_STUFF;
class SomeClass
{
public function __construct()
{
@somogyibence
somogyibence / enums.js
Created June 17, 2016 13:24
enums in JS
'use strict';
class EnumList {
constructor(enums) {
Object
.getOwnPropertyNames(enums)
.map(property => Object.defineProperty(this, property, {
enumerable: false,
configurable: false,
writable: false,