Skip to content

Instantly share code, notes, and snippets.

View whit3hawks's full-sized avatar
🎯
Focusing

Sharif khaleel whit3hawks

🎯
Focusing
View GitHub Profile
@agmm
agmm / nextjs-file-upload-api.js
Created January 31, 2020 23:03
Simple Nextjs File Upload — Backend API
// Backend
import formidable from 'formidable';
export const config = {
api: {
bodyParser: false,
},
};
export default async (req, res) => {
@jzpeepz
jzpeepz / birthdays.php
Last active October 10, 2022 01:46
Get recent/upcoming birthdays in Laravel
<?php
// Note: Adding 1 to the dates below accounts for
// diffences between PHP date('z') [starts at zero]
// and MySQL DAYOFYEAR [starts at 1]
// Want to use specific start and end date?
$start = date('z', strtotime('12/1/2021')) + 1;
$end = date('z', strtotime('1/30/2022')) + 1;
@whit3hawks
whit3hawks / Android RTL
Created April 28, 2015 06:15
Function to apply native RTL support for your Android applications.
private void applyRTL(){
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1){
getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
}
}
@shadcn
shadcn / gist:de147c42d7b3063ef7bc
Last active September 17, 2022 11:50
Convert a Hex string to UIColor in Swift
// Creates a UIColor from a Hex string.
func colorWithHexString (hex:String) -> UIColor {
var cString:String = hex.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()).uppercaseString
if (cString.hasPrefix("#")) {
cString = cString.substringFromIndex(1)
}
if (countElements(cString) != 6) {
return UIColor.grayColor()