Skip to content

Instantly share code, notes, and snippets.

View ozgurg's full-sized avatar
🏠
Working from home

Özgür Görgülü ozgurg

🏠
Working from home
View GitHub Profile
@ozgurg
ozgurg / README.md
Last active February 9, 2022 08:03
NGINX: Separating client, API, admin (Node.js & React/Vue/etc)
  • / = domain.com (Front-end app)
  • /admin = domain.com/admin (Front-end app)
  • /api = domain.com/api (Node.js, running on 3000 port)
@ozgurg
ozgurg / php-files-normalization.php
Last active February 9, 2022 08:04
PHP $_FILES Normalization (Single & Multiple)
<?php
function normalizeFiles()
{
$files = [];
$multiple = false;
foreach($_FILES as $name => $fileArray) {
if(is_array($fileArray["name"])) {
$multiple = true;
@ozgurg
ozgurg / PlayPauseView.java
Last active June 4, 2024 04:12
Android Animated Play Pause Button by using AnimatedVectorDrawable
public class PlayPauseView extends AppCompatImageView {
public static final int STATE_PLAY = 1;
public static final int STATE_PAUSE = 2;
private AnimatedVectorDrawableCompat mPlayToPauseAnim, mPauseToPlay;
private Animation mFadeOutAnim, mFadeInAnim;
public PlayPauseView(Context context) {
super(context);
Init(context);
@ozgurg
ozgurg / README.md
Last active February 9, 2022 08:05
Android ViewFlipper with listener

Usage (Java)

mViewFlipper.setOnChildChangeListener(new ViewFlipper.OnChildChangeListener() {  
  @Override  
  public void onChange(int whichChild) {  
      Toast.makeText(mActivity, String.valueOf(whichChild), Toast.LENGTH_SHORT).show();  
  }  
});
@ozgurg
ozgurg / str_pad_center.php
Last active March 17, 2024 04:22
It fills between two text with the given character until its length reach the given limit.
<?php
function str_pad_center($prefix, $suffix, $length, $char) {
$countWithoutChar = strlen($prefix) + strlen($suffix);
if($countWithoutChar > $length) {
return ""; // In your case, you may want to change this
}
$fill = str_repeat($char, $length - $countWithoutChar);
@ozgurg
ozgurg / README.md
Last active September 30, 2023 16:11
teknoseyir.com'da yorum veya gönderi yazarken yapıştırdığınızda panodaki görseli yorum veya gönderi görseli olarak ekler
@ozgurg
ozgurg / make-linear-gradient.scss
Created April 14, 2022 21:52
SASS make-linear-gradient function
@function make-linear-gradient($degree, $stops) {
$gradient: ();
@each $percentage, $color in $stops {
$gradient: append($gradient, $color $percentage, comma)
}
@return linear-gradient($degree, $gradient)
}
.sass {
@ozgurg
ozgurg / www.ts
Last active May 3, 2022 09:59
Node + Express bin/www with TypeScript
#!/usr/bin/env node
import debugFactory from "debug";
import http from "http";
import app from "./../app";
const debug = debugFactory(process.env.DEBUG);
/**
* Get port from environment and store in Express
*/
#!/usr/bin/env node
import debugFactory from "debug";
import dotenv from "dotenv";
import http from "http";
import app from "./../src/app.js";
const debug = debugFactory(process.env.DEBUG);
/**
@ozgurg
ozgurg / io.js
Last active August 15, 2022 14:27
Node.js type="module" path and fs helper. Put the file in the root folder
import { fileURLToPath } from "url";
import { dirname, join } from "path";
import { createReadStream, createWriteStream, existsSync, readFileSync, unlinkSync } from "fs";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const io = Object.freeze({
join,
existsSync,