Skip to content

Instantly share code, notes, and snippets.

@bulentala
bulentala / tailwind.css
Created December 29, 2020 21:05
Fixed sidebar - scrollable content
<div class="flex">
<aside class="h-screen sticky top-0">
// Fixed Sidebar
</aside>
<main>
// Content
</main>
</div>
@bulentala
bulentala / array in array map
Created December 5, 2020 18:49
array in array map
const dataItems = [{
title: "title1",
content: [{
imageUrl: "http://placehold.it/300x300",
title: "Campaigns",
description: "Short description explaining the use of this design in a single sentence."
},
{
imageUrl: "http://placehold.it/300x300",
title: "Events",
@bulentala
bulentala / Strip HTML Tags in JavaScript
Created May 11, 2020 11:51
Strip HTML Tags in JavaScript
var StrippedString = OriginalString.replace(/(<([^>]+)>)/ig,"");
@bulentala
bulentala / google Sheets Auto row Number
Last active May 7, 2020 17:34
google Sheets Auto row Number
=ARRAYFORMULA(ROW(A1:A))
=ARRAYFORMULA(ROW(A2:A)-1)
@bulentala
bulentala / swr fetch
Last active May 1, 2020 12:41
swr fetch
import React from "react";
import useSWR from 'swr';
const Index = () => {
const url = 'https://...';
const fetcher = (...args) => fetch(...args).then(res => res.json());
const { data, error } = useSWR(url, fetcher)
if (error) return <div>failed to load</div>;
if (!data) return <div>loading...</div>;
@bulentala
bulentala / terminal short cut
Created April 29, 2020 05:51
terminal short cut
Become a Command-Line Ninja with These Shortcuts
I’ve often found myself in such a frustrating situation, where I have to replace one keyword in the middle of a looong shell command that I just copied and pasted into the terminal (from StackOverflow or course 😅). Jumping over words with Alt-Arrow doesn’t work on all machines; how many left arrows and backspaces do I have to press, in order to replace that path/to/file or username in that genius command I stole from that SO answer??
Finally, I sat myself down to do some research on how to properly practice Ninjutsu in the terminal. As it turns out, roaming inside that command line environment is not that difficult at all!
I’m primarily a Z-Shell user, so this article will be more focused on ZSH. The shortcuts we are going to see here, however, should mostly work in BASH as well (sorry I don’t use FISH or other shells ).
Fun fact: shell key bindings actually defaults to “emacs mode”! You may have already discovered this if you are an emacs user. But for us m
@bulentala
bulentala / pass null
Created April 27, 2020 15:31
pass null
{(this.props.items || []).map(({ image, id }) => {
if (!image || !image.medium) {
return null
}
return (
<li key={id}>{image.medium}</li>
)
})}
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@bulentala
bulentala / slugify
Created November 23, 2019 03:05
slugify
// as={`/p/${slugify(tvMazeData.name, {
// lower: true,
// remove: /[*+~.()'"!:@]/g
// })}`}
function slugify(str) {
return str.toLowerCase().
replace(/&/g, 'and').
replace(/[^a-z0-9']+/g, '-').
replace(/^-|-$/g, '');
}