Skip to content

Instantly share code, notes, and snippets.

View abel-masila's full-sized avatar
⚛️
Shipping code!

Abel Masila abel-masila

⚛️
Shipping code!
View GitHub Profile
//Hoisting
y = 80; // Assign 5 to x
x=y+5 // sum up 5 with the value of y
var y; // Declare y
//JavaScript only hoists declarations, not initializations.
var name = "Abel";
public class Dependant
{
public string id_number { get; set; }
public string relationship { get; set; }
public string last_name { get; set; }
public string first_name { get; set; }
public string gender { get; set; }
public string birthdate { get; set; }
public string photo { get; set; }
}
SELECT *
FROM ItemsEntity where item_id=1
FOR JSON AUTO
@abel-masila
abel-masila / AppServiceProvider.php
Created February 7, 2018 15:57
yntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table users add unique users_email_unique(email))
use Illuminate\Support\Facades\Schema;
public function boot()
{
Schema::defaultStringLength(191);
}
function loop(arr) {
// i IS NOT known here
// j IS NOT known here
for( var i = 0; i < arr.length; i++ ) {
// i IS known here
}
// i IS known here
// j IS NOT known here
import React, { Component } from 'react';
import loading_icon from '../images/ellipsis.gif';
export default class BlankState extends Component {
constructor(props){
super(props);
let { data = [], dataName = 'Info', isDataLoading, customMessage } = this.props;
import validator from 'validator';
class FormValidator{
constructor(validations) {
// validations is an array of validation rules specific to a form
this.validations = validations;
}
validate(state){
// start out assuming valid
let validation = this.valid();
axios.get(geocodeURL).then((response)=>{
if(response.data.status==='ZERO_RESULTS'){
throw new Error('Unable to find that address!');
}
const lat=response.data.results[0].geometry.location.lat;
const lng=response.data.results[0].geometry.location.lng;
const weatherURL=`https://api.darksky.net/forecast/3708bcb6e2a477e7fb94de8fd3ecdfab/${lat},${lng}`;
//async promise with user input
const asyncAdd=(a,b)=>{
return new Promise((resolve,reject)=>{
setTimeout(()=>{
if(typeof a=== 'number' && typeof b==='number'){
resolve(a+b);
}else {
reject('Arguments must be numbers');
}
},1500)
const selectedGoods = quote.selected_goods;
if(this.goodsValidator.allValid()){
this.goodsValidator.hideMessages();
selectedGoods.push(selectedGood);
}else {
this.goodsValidator.showMessages();
// rerender to show messages for the first time
this.forceUpdate();
}