Skip to content

Instantly share code, notes, and snippets.

View sarpavci's full-sized avatar
🦎
c h a m e l e o n

Sarp AVCI sarpavci

🦎
c h a m e l e o n
View GitHub Profile
@sarpavci
sarpavci / delete-stale-branches.js
Last active June 23, 2023 15:14
go to stale branch list page then run this script in devtools console 👍 `deleteBranches("org", "repo")`
async function deleteBranches(org, repo) {
await Promise.allSettled(
Array
.from(document.getElementsByClassName('js-branch-delete-button'))
.map((elm) => new Promise((resolve, reject) => {
const branchName = elm.getAttribute('title').replace('Delete ', '');
const deleteUrl = `https://github.com/${org}/${repo}/branches/${branchName}`;
const authenticityToken = elm.closest('form').querySelector('[name="authenticity_token"]').value;
const method = 'POST';
import json
import os
from supabase import create_client, Client
# https://github.com/supabase-community/supabase-py
url: str = 'https://xzdacscxdkwhvzcnexwt.supabase.co' # os.environ.get("SUPABASE_URL")
key: str = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh6ZGFjc2N4ZGt3aHZ6Y25leHd0Iiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTY3NTgwNjIwNywiZXhwIjoxOTkxMzgyMjA3fQ.OicX8vKHCvO0eQwXsWi2TkXpM0fjW3glJ461NiBeygg' # os.environ.get("SUPABASE_KEY")
supabase: Client = create_client(url, key)
# Initialize app
function markVideoAsNotInterested() {
const selectorOptionsBtn = document.querySelectorAll('button.yt-icon-button');
const filterVideoItemButton = (btn) => {
return !!btn.closest('.ytd-rich-grid-media');
};
const findPopup = () => {
const selectorPopupContainer = document.getElementsByTagName('ytd-popup-container');
@sarpavci
sarpavci / challenge.md
Created March 30, 2022 13:59
Typescript NestJS Back-end Challenge

Challange:

OAuth 2.0 Implementation

Tech Requirements:

  • Typescript
  • NestJS
  • TypeORM
  • PostgreSQL

Description:

With the technology mentioned above, OAuth 2.0 should be implemented using the NestJS framework. Architectural approaches are completely left to you. This project to be prepared should be usable like a microservice. Do not forget to include static analysis tools such as ESLint and Prettier, which are frequently used in the JS/TS ecosystem. Writing tests for the operations to be done is nice to have.

@sarpavci
sarpavci / ty-scrape.js
Created December 27, 2020 13:21
Trendyol scrape example
const fs = require('fs');
const _ = require('lodash');
const axios = require('axios');
const async = require('async');
const getData = async (link) => {
try {
const response = await axios.get(link);
var result = JSON.parse(response.data.match(/((?<=type=application\/ld\+json\>))(.*)(?=\<\/script\>)/g)[0].replace(/@/g, "").replace(/https:\/\/schema\.org\//g, ""));
@sarpavci
sarpavci / front-end-case.md
Last active September 8, 2021 13:26
Front-end Case

Chat Application

image

The project is very simple, a standard chat application. The interface of the project will be the same as the image above. The user will be able to register, login and logout. Logged in users will appear in the list on the left and when clicked, the active conversation window will change with the selected user. The message on the right will be the sender of the person who receives the messages on the left.

Technologies to be used;

  • Node.js (Template Engine: Nunjucks)
  • HTML
  • LESS - SCSS - SCSS
@sarpavci
sarpavci / create-swap.sh
Last active October 6, 2020 21:53
Ubuntu create swap space
#!/bin/sh
swapsize=2048
grep -q "swapfile" /etc/fstab
if [ $? -ne 0 ]; then
echo 'swapfile not found. Adding swapfile.'
fallocate -l ${swapsize}M /swapfile
chmod 600 /swapfile
@sarpavci
sarpavci / .bash_aliases
Last active September 24, 2021 20:54
Bash aliases only git commands
function git-commit() {
ref=$(git symbolic-ref HEAD --short)
git commit -m"$ref $@"
}
function git-reset-hard() {
git reset --hard origin/"$@"
}
function git-open-pr() {
ref=$(git symbolic-ref HEAD --short)
repo=$(git remote get-url origin | sed -En "s/git@(.*):(.*)\/(.*).git/https:\/\/\1\/\2\/\3/p")
@sarpavci
sarpavci / create-homestead-user.sql
Last active October 12, 2020 10:55
Mysql create homestead user
CREATE USER 'homestead'@'localhost' IDENTIFIED WITH mysql_native_password BY 'secret';
GRANT ALL PRIVILEGES ON * . * TO 'homestead'@'localhost';
FLUSH PRIVILEGES;
-- Show user grants
-- SHOW GRANTS username;
-- Revoke permissions
-- REVOKE ALL PRIVILEGES ON * . * TO 'homestead'@'localhost';
@sarpavci
sarpavci / jenkins-grunt-stdout-parser.js
Created April 13, 2020 15:26
Jenkins Grunt StdOut Parser
const fs = require('fs');
const replacementList = [
{
find: /\\u001b\[24m\\n/gmi,
replace: '\n',
},
{
find: /4m/gmi,
replace: '',