Skip to content

Instantly share code, notes, and snippets.

View achimoraites's full-sized avatar
🔬
Nerdy Stuff

Achilles Moraites achimoraites

🔬
Nerdy Stuff
View GitHub Profile
@achimoraites
achimoraites / unique-letter-combination-permutation.ts
Last active July 26, 2022 06:25
Having fun with permutations
// example usage
const chars = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z".split(' ');
const limit = 2;
console.log(generator(limit, chars));
/**
* Unique letter combination permutations generator that only generates unique strings like
* 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK',
let table = document.querySelector("tbody");
const _self = this;
// this way we avoid data binding
_self.dragNdrop = JSON.parse(JSON.stringify(_self.formItems));
Sortable.create(table, {
onEnd({
newIndex,
oldIndex
}) {
@achimoraites
achimoraites / history.component.spec.ts
Created March 21, 2020 14:18
Advanced Angular Testing with Jasmine
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { HistoryComponent } from './history.component';
fdescribe('HistoryComponent', () => {
let component: HistoryComponent;
let fixture: ComponentFixture<HistoryComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
@achimoraites
achimoraites / fibonacci.js
Created February 6, 2020 09:57
Generate fibonacci numbers using generators in Javascript
/**
* Generate fibnacci numbers using generators
* A simple illustration of the power that generators
* can bring in our code
*
* generator is from the https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators
*/
function* fibonacci() {
@achimoraites
achimoraites / index.js
Created November 13, 2018 15:09
Simple Express Server to serve a react app located in client dir
const express = require('express');
const app = express();
// serve up production assets
app.use(express.static('client/build'));
// serve up the index.html if express does'nt recognize the route
const path = require('path');
app.get('*', (req, res) => {
@achimoraites
achimoraites / jsx
Created October 24, 2018 11:30
Using spotify api without headaches
search() {
console.log('this.state', this.state);
const BASE_URL = 'https://api.spotify.com/v1/search?';
const FETCH_URL = `${BASE_URL}q=${this.state.query}&type=artist&limit=1`;
// get your access token : https://developer.spotify.com/console/get-search-item/
// click get token button , copy paste the token below and you are good to go
var accessToken = 'YOUR_TOKEN';
var myOptions = {
class Example {
private ss: string;
constructor(s:string){
this.ss = s;
}
// Functional Cohesion
parseString(s: string): string {
this.ss = s + "...";
return this.ss;
}
@achimoraites
achimoraites / AndroidManifest.xml
Created February 24, 2018 16:14
Sample code for a simple image picker for android
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.github.cyb3rn4u7.imagepicker">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"