Skip to content

Instantly share code, notes, and snippets.

View yoosuf's full-sized avatar
🌍
Somewhere in Asia

yoosuf

🌍
Somewhere in Asia
View GitHub Profile
@yoosuf
yoosuf / findWord.go
Last active March 19, 2023 05:48
Scopic Live Code Test : You're given an array that shows the relative positions of the letters of a word. Your task is to find the word hidden behind the array.
package main
import (
"fmt"
)
func findWord(arr []string) string {
word := ""
temp := make(map[string]string)
@yoosuf
yoosuf / stopnremoveall.sh
Created August 14, 2019 01:48
Stop and remove all docker containers and images (Docker)
# List all containers (only IDs)
docker ps -aq
# Stop all running containers
docker stop $(docker ps -aq)
# Remove all containers
docker rm $(docker ps -aq)
# Remove all images
@yoosuf
yoosuf / anagram.rb
Created October 31, 2018 05:56
Simple Anagram with Ruby
def anagram(str1, str2)
if str1.nil? || str2.nil? || str1.empty? || str2.empty?
return false
end
demo1 = str1.split("").sort
demo2 = str2.split("").sort
test1 = noirmalise(demo1)
test2 = noirmalise(demo2)

Keybase proof

I hereby claim:

  • I am yoosuf on github.
  • I am yoosuf (https://keybase.io/yoosuf) on keybase.
  • I have a public key ASC_dKx0ccA1QlANU9Yw__6uEIvFZV6WCE3eFhMPBsRs3go

To claim this, I am signing this object:

import React, { Component } from 'react';
import { BrowserRouter as Router, Route } from 'react-router-dom'
import Layout from './components/layout/Layout'
import Home from './components/Home'
import Explore from './components/Explore'
import Profile from './components/Profile'
@yoosuf
yoosuf / DailyBackupAndSync.php
Created January 5, 2017 14:48
Daily backup and Restore Laravel Command
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Storage;
class DailyBackupAndSyncCommand extends Command
{
/**
@yoosuf
yoosuf / datadump.sql
Created November 7, 2016 05:50
Member::whereJsonContains()
INSERT INTO `members` (`id`, `name`, `msisdn`, `token`, `api_token`, `settings`, `created_at`, `updated_at`)
VALUES
(1, NULL, '343434343434', '303273', 'GIUalPNIiiBIiQsBeJDeeMvxhgL9wrDOrlE5AqGyZvHFWwPuuBPjHziTWZHu2xuM', '{\"topics\":[\"topic1\",\"topic2\"]}', '2016-11-05 07:56:55', '2016-11-05 07:56:55'),
(2, 'Haiooo', '0776002114', '150093', '5peAwwfkYo19sRQTZq21ePMynJrRlTLuTwvxGVoSvLIz4jRVQ830nnflZGv9cUK3', '{\"topics\":[\"topic1\",\"topic2\",\"topic3\",\"topic4\"]}', '2016-11-06 02:27:31', '2016-11-06 02:27:53');
@yoosuf
yoosuf / active.blade.php
Created May 5, 2016 17:38
Setting Bootstrap navbar active class in Laravel 5
<ul class="nav nav-second-level">
<li class="{{ Request::segment(1) === 'programs' ? 'active' : null }}">
<a href="{{ url('programs' )}}" ></i> Programs</a>
</li>
<li class="{{ Request::segment(1) === 'beneficiaries' ? 'active' : null }}">
<a href="{{url('beneficiaries')}}"> Beneficiaries</a>
</li>
<li class="{{ Request::segment(1) === 'indicators' ? 'active' : null }}">
<a href="{{url('indicators')}}"> Indicators</a>
</li>
@yoosuf
yoosuf / tands.php
Last active March 27, 2016 11:19
Managing everything is WordPress is messy, so I wanted to send a POST request when a post is published
<?php
/**
* @package tands
* @version 0.1
*/
/*
Plugin Name: Trigger and Shoot by Yoosuf
Plugin URI: https://github.com/yoosuf
Description: This plugin simply pass the post details to where ever you want for what ever the porpose.
Author: Yoosuf Muhammad
@yoosuf
yoosuf / transaction.php
Last active July 11, 2017 16:51
WordPress: When a post is published, trigger an event
<?php
/*
* Add this function somewhere in functions.php
* You will see there is nothing is magic in WordPress
**/
function on_all_status_transitions( $new_status, $old_status, $post ) {
if ('publish' == $new_status && 'publish' != $old_status && 'trash' != $old_status) {
// Your code comes here