Skip to content

Instantly share code, notes, and snippets.

@RaymondMwaura
RaymondMwaura / codility_solutions.txt
Created April 20, 2024 12:37 — forked from lalkmim/codility_solutions.txt
Codility Solutions in JavaScript
Lesson 1 - Iterations
- BinaryGap - https://codility.com/demo/results/trainingU2FQPQ-7Y4/
Lesson 2 - Arrays
- OddOccurrencesInArray - https://codility.com/demo/results/trainingFN5RVT-XQ4/
- CyclicRotation - https://codility.com/demo/results/trainingSH2W5R-RP5/
Lesson 3 - Time Complexity
- FrogJmp - https://codility.com/demo/results/training6KKWUD-BXJ/
- PermMissingElem - https://codility.com/demo/results/training58W4YJ-VHA/
@RaymondMwaura
RaymondMwaura / randomDarkColor.js
Created January 27, 2022 15:38 — forked from Chak10/randomDarkColor.js
Javascript Random Dark Color
function randDarkColor() {
var lum = -0.25;
var hex = String('#' + Math.random().toString(16).slice(2, 8).toUpperCase()).replace(/[^0-9a-f]/gi, '');
if (hex.length < 6) {
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
}
var rgb = "#",
c, i;
for (i = 0; i < 3; i++) {
c = parseInt(hex.substr(i * 2, 2), 16);
@RaymondMwaura
RaymondMwaura / rootReducer.js
Created September 28, 2020 12:48 — forked from frankchang0125/rootReducer.js
Reset all reducers back to their initial states when user logout
import {combineReducers} from 'redux';
import { LOGOUT } from '../common/constants';
import { UnauthorizedErrorReducer } from '../common/commonReducers';
import FirstReducer from './FirstReducer';
import SecondReducer from './SecondReducer';
import ThirdReducer from './ThirdReducer';
/* In order to reset all reducers back to their initial states when user logout,
* rewrite rootReducer to assign 'undefined' to state when logout
*
@RaymondMwaura
RaymondMwaura / untrusted_lvl17.js
Created September 20, 2020 23:26
Solution -> Level 17 - Untrusted
/***************
* pointers.js *
***************
*
* You! How are you still alive?
*
* Well, no matter. Good luck getting through this
* maze of rooms - you'll never see me or the Algorithm again!
*/
/* eslint-disable jsx-a11y/label-has-associated-control */
/* eslint-disable jsx-a11y/control-has-associated-label */
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Redirect } from 'react-router-dom';
import propTypes from 'prop-types';
import LoadingButton from './templates/Button';
import RadioInput from './templates/RadioInput';
import createTripFields from '../utils/createTripFields';
import {
// This test confirms if the feature that allows a user to add an article works
describe('POST /article', () => {
it('Create an article if given complete request by user', async () => {
const res = await chai.request(server)
.post('/api/v1/article')
.field('username', 'rmwaura')
.field('text', 'A very well written article')
.field('date', '2019-10-31');
expect(res.status).to.equal(200);
@RaymondMwaura
RaymondMwaura / gitproxy-socat
Created July 14, 2017 09:28 — forked from sit/gitproxy-socat
A simple wrapper around socat to use as a git proxy command
#!/bin/sh
# Use socat to proxy git through an HTTP CONNECT firewall.
# Useful if you are trying to clone git:// from inside a company.
# Requires that the proxy allows CONNECT to port 9418.
#
# Save this file as gitproxy somewhere in your path (e.g., ~/bin) and then run
# chmod +x gitproxy
# git config --global core.gitproxy gitproxy
#
# More details at http://tinyurl.com/8xvpny
<?php
namespace App\Http;
/**
* Description of VideoStream
*
* @author Rana
* @link https://gist.github.com/vluzrmos/d5682ad426525196d069
*/