Skip to content

Instantly share code, notes, and snippets.

View ridvanaltun's full-sized avatar
🐴
prostagma?

Rıdvan Altun ridvanaltun

🐴
prostagma?
View GitHub Profile
@ridvanaltun
ridvanaltun / React-Native-WebView-Cookies.js
Created July 24, 2019 13:31 — forked from xxxxlr/React-Native-WebView-Cookies.js
React Native Trick: Get Cookies of WebView without using any native modules such as react-native-cookies. Might be helpful for getting JWT while making OAuth2 👽
// @flow
import React, { Component } from 'react';
import {
WebView,
} from 'react-native';
class LoginScreen extends Component {
state = {
cookies : {},
@ridvanaltun
ridvanaltun / GitCommitEmoji.md
Created July 25, 2019 07:17 — forked from parmentf/GitCommitEmoji.md
Git Commit message Emoji
@ridvanaltun
ridvanaltun / decorators.py
Last active July 4, 2022 20:27
Django REST Framework Custom Decorators
from rest_framework import status
from rest_framework.response import Response
from rest_framework_simplejwt.authentication import JWTAuthentication
# parametre olarak verilen methodlara sadece admin user erişebilir demek
# db ile iletişim kuruluyor, admin kullanıcısı olduğu için db ile iletişimini önemsemedim
def only_admin(methods=[], err_message="Admin authorization required."):
def decorator(view_function):
def decorated_function(request, *args, **kwargs):
@ridvanaltun
ridvanaltun / SCAN_CORRUPTED_VIDEOS.md
Last active December 3, 2023 11:32
How to check if a video file is corrupted?

Download ffmpeg from here, download *-win64-gpl.zip for Windows.

Install ffmpeg for Ubuntu

sudo apt install ffmpeg

Below command will give you a log file. If no error found, the log file will be empty.

@ridvanaltun
ridvanaltun / macOS-X-El-Capitan-with-Vagrant.md
Last active June 25, 2021 09:46
macOS X El Capitan with Vagrant

Overview

Version: OS X El Capitan 10.11.6

Build Version: 15G31

Provider: VirtualBox

System Requirements

@ridvanaltun
ridvanaltun / macOS-X-Big-Sur-with-Vagrant.md
Last active November 2, 2021 18:31
macOS X Big Sur with Vagrant
@ridvanaltun
ridvanaltun / user_aliases.cmd
Last active July 8, 2021 11:59
User Aliases for Cmderr
;= @echo off
;= rem Call DOSKEY and use this file as the macrofile
;= %SystemRoot%\system32\doskey /listsize=1000 /macrofile=%0%
;= rem In batch mode, jump to the end of the file
;= goto:eof
;= Common directories
desktop=cd /d "%HOME%"\Desktop"
home=cd /d "%HOME%"
@ridvanaltun
ridvanaltun / create-vagrant-box.md
Created June 29, 2021 19:16
Create Vagrant box from existing Vagrant Box
# create an example ubuntu box
vagrant init bento/ubuntu-18.04

# deploy it
vagrant up

# connect to the box over ssh
vagrant ssh
@ridvanaltun
ridvanaltun / async-await-error-handling.md
Last active July 8, 2021 10:39
A clever way to handling errors in async-await

logic

async function fetchData() {
  try{
    const data = await fetch()
    return [data, null]
  } catch(error) {
    return [null, error]
 }
@ridvanaltun
ridvanaltun / execute-shell-commands-in-node.md
Created July 7, 2021 22:43
Execute shell commands in Node
import { exec } from 'child_process';

/**
 * Execute simple shell command (async wrapper).
 * @param {String} cmd
 * @return {Object} { stdout: String, stderr: String }
 */
async function sh(cmd) {
 return new Promise(function (resolve, reject) {