Skip to content

Instantly share code, notes, and snippets.

View JuliusNM's full-sized avatar
🎯
Focusing

Julius JuliusNM

🎯
Focusing
  • Jello
  • Nairobi - Kenya
View GitHub Profile
@JuliusNM
JuliusNM / read.yml
Last active January 27, 2021 11:08
openapi: 3.0.0
info:
title: NodeBB Read API
version: 1.15.0
contact:
email: support@nodebb.org
license:
name: GPL-3.0
description: >-
# Overview
@JuliusNM
JuliusNM / nairuby.rb
Created February 18, 2020 07:04
Nairuby code challenge(Divisible Sum Pairs)
#You are given an array of n integers, ar = [ ar[0], ar[1],...,ar[n-1]] , and a positive integer, k. Find and print the number of (i, j) pairs where i<j and ar[i]+ ar[j] is divisible by k.
def divisibleSumPairs(ar, k)
ar.combination(2).to_a.select{ |a| (a.index(a[0]) < a.index(a[1])) && ((a[0] + a[1]) % k == 0)}.count
end
array = [1, 2, 3, 4, 5, 6]
x = 5
p divisibleSumPairs(array, x)
bool get hasScrolledBody {
for (_NestedScrollPosition position in _innerPositions) {
if (
position.minScrollExtent != null &&
position.pixels != null &&
position.pixels > position.minScrollExtent
) {
return true;
}
}
@JuliusNM
JuliusNM / compound_words.py
Last active June 25, 2019 13:05
Compound word exercise
# Assume we have a list of words from the English dictionary, like:
# english_words = ["water","big","apple","watch","banana","york","amsterdam","orange","macintosh","bottle","book"]
# And another long list of string to process, write a function to identify "compound words" and return them:
# output: ["applewatch","bigbook","waterbottle"]
english_words = ["water","big","apple","watch","banana","york","amsterdam","orange","macintosh","bottle","book"]
inputWords = ["paris","applewatch","ipod","amsterdam","bigbook","orange","waterbottle"]
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context)=> MaterialApp(
title: 'Nested Views',
theme: ThemeData(
brightness: Brightness.light,
primaryColor: Color(0xFF44318e),
accentColor: Color(0xFFe98074),
fontFamily: 'Quicksand',
import 'dart:convert';
import 'dart:math';
import 'dart:typed_data';
import 'package:asn1lib/asn1lib.dart';
import 'package:convert/convert.dart' as convert;
import 'package:ejenti_master_agent/myGenerator.dart';
import 'package:encrypt/encrypt.dart';
import 'package:pointycastle/export.dart';
@JuliusNM
JuliusNM / subsets.py
Created October 13, 2016 17:16
Weird_sort, Subset generator
def subsets(items):
subsets = []
for code in range(0, 2**len(items)):
code = ("{0:0" + str(len(items)) + "b}").format(code, len(items))
print(code)
# for i in range(0,len(items)):
subset = set()
for i, c in enumerate(code):
@JuliusNM
JuliusNM / quad.rb
Last active October 12, 2016 20:44
Quadratic Equation Solver, Simultaneous Equation Solver, Meeting organizer
#Julius and Mercy Quadratic Equation Solver
#Implementation of the formula x= (-b+- (b**2-4ac)**2)/2a
def quad_values(a,b,c)
a = a.to_f
b = b.to_f
c = c.to_f
d = (b**2) - (4*a*c)
if d >= 0
d = Math.sqrt(d)
def product_array(arr)
prd=1
arr.each do |x|
x > 0 ? prd= prd*x : prd = prd
end
prd
end
def new_array (arr)
zero_count = arr.count(0)
def product_array(arr)
prd=1
arr.each do |x|
x > 0 ? prd= prd*x : prd = prd
end
prd
end
def new_array (arr)
zero_count = arr.count(0)