Skip to content

Instantly share code, notes, and snippets.

View cedrickvstheworld's full-sized avatar
:octocat:
up to no good

cedrickvstheworld

:octocat:
up to no good
View GitHub Profile
@cedrickvstheworld
cedrickvstheworld / alphabet-counter.js
Created March 10, 2020 01:35
1: A , 26: Z, 27: AA
function alphabetCounter(counter) {
counter = Math.abs(counter)
counter = !counter ? 1 : counter
let remainder = counter % 26
let quotient = Math.floor(counter / 26)
let result = remainder ? String.fromCharCode(64 + remainder) : (--quotient, 'Z');
return quotient ? alphabetCounter(quotient) + result : result;
}
let testArr = [...Array(23).keys()]
function chunk(arr, size) {
let chunkie = []
let newConstruct = []
for (let i in arr) {
if (chunkie.length < size - 1) {
chunkie.push(arr[i])
if (arr.length === parseInt(i) + 1) {
newConstruct.push(chunkie)
@cedrickvstheworld
cedrickvstheworld / flatten-object.js
Created February 10, 2020 04:50
flatten js object to Depth = 1
let oldData = {
age: 3,
name: "dudeson",
height: 70,
type: 3,
address: {
city: 'Manila',
street: 'street 66',
province: {
district: {
/**
* y = a + bx
*
*
* a = ʏ̅ - bx̅
*
* b = Σxy - nx̅ʏ̅ / Σx^2 - nx̅^2
*
* */
filebeat.inputs:
- type: docker
containers.ids: '*'
processors:
- add_docker_metadata: ~
output.elasticsearch:
hosts: ["http://192.168.99.103:9200"]
username: "elastic"
password: "changeme"
@cedrickvstheworld
cedrickvstheworld / dataFilter.js
Last active December 10, 2019 02:02
dataFilter.js
/**
* order, orderBy, search by text, and set offset / limit for array of objects (depth = 1)
*/
const sample = [
{
name: "cDudeson",
age: 32
},
{
function getPeakHours(feeds, consideration) {
const feedCount = feeds.length
// check if all feeds has a length of 12
for (let i in feeds) {
if (feeds[i].length !== 24) {
return 'rejected: feed must have a length of 24'
}
}
// get hour averages
param = int(input('Enter a number: '))
line_length = (param * 2) - 1
for i in range(param + 1)[::-1]:
multiplier = ((i * 2) - 1)
center_string = str(i) * multiplier
if multiplier < line_length:
sides = []
for ii in range(i + 1, param + 1):
sides.append(str(ii))
# item 1
i = 0
while i <= 5:
asteriskshits = '*' * i
spacing = ' ' * (5 - i) * 2
print( asteriskshits, spacing, asteriskshits)
i += 1
# item 2
from math import *
from tkinter import *
from tkinter import ttk
app = Tk()
app.title('Prime number Checker')
def primecheck(x):
xa = sqrt(x)
if (xa % 1) == 0: