Skip to content

Instantly share code, notes, and snippets.

View manuelgeek's full-sized avatar
😎
#mANuEl💯

Magak Emmanuel manuelgeek

😎
#mANuEl💯
View GitHub Profile
@manuelgeek
manuelgeek / example.ex
Created July 30, 2020 18:08 — forked from ck3g/example.ex
How to read from STDIN in Elixir (for HackerRank)
defmodule Solution do
#Enter your code here. Read input from STDIN. Print output to STDOUT
end
array_length = IO.read(:stdio, :line)
array = IO.read(:stdio, :line)
array_length
|> String.trim
|> String.to_integer
@manuelgeek
manuelgeek / test.py
Created May 4, 2020 11:28
Simple Django gist to show count
def get_count(self, request, *args, **kwargs):
recons_0 = ReconStatus.objects.filter(ageing_days__range=[0,30], deleted=False).count()
recons_30 = ReconStatus.objects.filter(ageing_days__range=[30,60], deleted=False).count()
recons_60 = ReconStatus.objects.filter(ageing_days__range=[60,90], deleted=False).count()
recons_90 = ReconStatus.objects.filter(ageing_days__gte = 90, deleted=False).count()
return Response({'recons_0': recons_0, 'recons_30': recons_30, 'recons_60': recons_60, 'recons_90': recons_90})
@manuelgeek
manuelgeek / config.exs
Created March 25, 2020 13:56 — forked from nimish-mehta/config.exs
Configure Logging to File in Phoenix
# Configures Elixir's Logger to log to file
# ensure https://github.com/onkel-dirtus/logger_file_backend
# is installed in deps of the project in mix.exs
# reuses the original phoenix logging format.
config :logger, backends: [{LoggerFileBackend, :request_log}],
format: "$time $metadata[$level] $message\n",
metadata: [:request_id]
# Keep a seperate log file for each env.
# logs are stored in the root directory of the application
@manuelgeek
manuelgeek / CORS.php
Created March 25, 2020 12:46
Laravel CORS middleware, remember to check and add necessary headers and change the origin accordingly
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Response;
class CORS
{
/**
@manuelgeek
manuelgeek / addLetters.js
Created January 8, 2020 11:54
Your task is to add up letters to one letter. The function will be given a variable amount of arguments, each one being a letter to add. Notes: Letters will always be lowercase. Letters can overflow (see second to last example of the description) If no letters are given, the function should return 'z' fom https://www.codewars.com/kata/alphabetic…
function addLetters() {
var alphabet = "abcdefghijklmnopqrstuvwxyz".split('');
var sum = 0;
if(arguments.length === 0){
console.log(alphabet[26-1]);
return alphabet[26-1];
}
for (var i = 0; i < arguments.length; ++i){
let l = arguments[i].toLowerCase();
let t = alphabet.indexOf(l) + 1;
@manuelgeek
manuelgeek / .grub
Created November 24, 2019 12:20
Ubuntu Force windows boot loader to point to ubuntu grub
You can now reboot your computer.
Please do not forget to make your BIOS boot on sda2/EFI/ubuntu/shimx64.efi file!
If your computer reboots directly into Windows, try to change the boot order in your BIOS.
If your BIOS does not allow to change the boot order, change the default boot entry of the Windows bootloader.
For example you can boot into Windows, then type the following command in an admin command prompt:
bcdedit /set {bootmgr} path \EFI\ubuntu\shimx64.efi
@manuelgeek
manuelgeek / location.js
Created August 13, 2019 12:08
simple JS to get location, front end ......>>>> vue
ipLookUp() {
axios.get('http://ip-api.com/json',{},{headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, PUT, POST, DELETE, OPTIONS',
'Content-Type': 'application/json',
}})
.then(response => {
console.log('User\'s Location Data is ', response);
console.log('User\'s Country', response.data.country);
this.getAddress(response.data.lat, response.data.lon)
@manuelgeek
manuelgeek / toast.js
Created August 4, 2019 14:32
a simple snippet
import Vue from 'vue'
import BootstrapVue from 'bootstrap-vue'
Vue.use(BootstrapVue)
export function toaster(msg = 'Message', title='Success',position='b-toaster-top-right', append = false){
return this.$bvToast.toast( msg, {
title: title,
toaster: position,
variant: 'success',
solid: true,
appendToast: append
@manuelgeek
manuelgeek / axios-catch-error.js
Created August 2, 2019 09:01 — forked from fgilio/axios-catch-error.js
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
{"version":1,"resource":"file:///Users/manuelgeek/React/TheRoom/theroom-monorepo/apps/api/src/test/employer-service/opportunity-payment/__mocks__/stripe.ts","entries":[{"id":"olQy.ts","source":"renamed.source","timestamp":1658214641155},{"id":"QHt3.ts","timestamp":1658214718170}]}