Skip to content

Instantly share code, notes, and snippets.

@menemsalama
menemsalama / vuedraggable-example.vue
Created December 30, 2018 23:17
showcase for sorting sections with vuedraggable library
<template>
<div id="app">
<Vuedraggable v-model='dashboardSectionsComponents' @update="handleDashboardSectionsSort">
<!-- NOTE I think we might need to look at example like this, on how to pass dynamic props to dynamic component https://stackoverflow.com/questions/43658481/passing-props-dynamically-to-dynamic-component-in-vuejs?answertab=active#tab-top -->
<!-- NOTE but let's use this for now. -->
<component
v-for="component in dashboardSectionsComponents"
:is="component.name"
:key="component.id"
v-bind="$data"
# https://www.hackerrank.com/challenges/ctci-ransom-note
#!/bin/ruby
m,n = gets.strip.split(' ')
m = m.to_i
n = n.to_i
magazine = gets.strip.split(' ')
ransom = gets.strip.split(' ')
def ransom_note(ransom, magazine)
/*
Subset
In today's challenge we want to implement a function is_subset, which checks if one array is the subset of another.
Subset means that the first array is included in the second array. Ignore duplicates.
- Example: [1, 2, 3].is_subset([1,2,3,4]) => returns true
- Example: [1, 2, 3].is_subset([1,3,4]) => returns false
- Example: [1, 1, 2, 3].is_subset([1,2,3]) => returns true
/* Counting Words
We found an article on Wikipedia and we decide to save this article as a string
and count the occurrence of all the different words in the article. In other words,
for a given string we want to know the number of times **each word** appears in the article.
> Note: be weary of capitalization.
*/
var my_article =
const dataSample = {
buy: [ "purchase" ],
big: [ "great", "large" ],
};
function synonyms(data, word) {
const result = {
word,
synonyms: data[word] || [],
};
package main
import (
"fmt"
"strings"
)
func isPalindrome(str string) bool {
var size, count int
package main
import (
"fmt"
)
type P struct {
g, p int
}
package handler
import (
"io"
"net/http"
)
type Handle struct {
Action string
Method string
@menemsalama
menemsalama / r
Created March 27, 2017 01:25
simple router in Go
package router
import (
"net/http"
"net/url"
"strings"
)
// Handle h
type Handle func(http.ResponseWriter, *http.Request, url.Values)
@menemsalama
menemsalama / urlShortener.go
Created March 3, 2017 21:37
URL shortener in Go
package main
import (
"encoding/json"
"log"
"net/http"
"time"
"github.com/couchbase/gocb"
"github.com/gorilla/mux"