Skip to content

Instantly share code, notes, and snippets.

@xmhafiz
xmhafiz / PhoneHelper.swift
Created October 20, 2019 23:36
To get country prefix phone code using Swift 5
import Foundation
import CoreTelephony
struct PhoneHelper {
static func getCountryCode() -> String {
guard let carrier = CTTelephonyNetworkInfo().subscriberCellularProvider, let countryCode = carrier.isoCountryCode else { return "+" }
let prefixCodes = ["AF": "93", "AE": "971", "AL": "355", "AN": "599", "AS":"1", "AD": "376", "AO": "244", "AI": "1", "AG":"1", "AR": "54","AM": "374", "AW": "297", "AU":"61", "AT": "43","AZ": "994", "BS": "1", "BH":"973", "BF": "226","BI": "257", "BD": "880", "BB": "1", "BY": "375", "BE":"32","BZ": "501", "BJ": "229", "BM": "1", "BT":"975", "BA": "387", "BW": "267", "BR": "55", "BG": "359", "BO": "591", "BL": "590", "BN": "673", "CC": "61", "CD":"243","CI": "225", "KH":"855", "CM": "237", "CA": "1", "CV": "238", "KY":"345", "CF":"236", "CH": "41", "CL": "56", "CN":"86","CX": "61", "CO": "57", "KM": "269", "CG":"242", "CK": "682", "CR": "506", "CU":"53", "CY":"537","CZ": "420", "DE": "49", "DK": "45", "DJ":"253", "DM": "1", "DO": "1", "DZ": "213", "EC": "593"
@ConnerWill
ConnerWill / ANSI-escape-sequences.md
Last active May 11, 2024 13:18
ANSI Escape Sequences cheatsheet

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@echo-akash
echo-akash / LinkedList.c
Last active May 11, 2024 13:17
Implementation of Singly Linked List in C
#include<stdio.h>
#include<stdlib.h>
struct node //make node for linked list using structure
{
int value; //value part of node contains the element
struct node *next; //the next part of node contains the address of next element of list
};
struct node *head; //contains the address of first element of linked list
#include <windows.h>
#include <mmdeviceapi.h>
#include <audioclient.h>
#include <assert.h>
#define _USE_MATH_DEFINES
#include <math.h> // for sin()
#include <stdint.h>
@chrisdigital
chrisdigital / Frontend user profile in WordPress
Created May 6, 2013 13:27
Setting up a editable user profile in WordPress on the frontend.
//How to edit a user profile on the front end?
//http://wordpress.stackexchange.com/questions/9775/how-to-edit-a-user-profile-on-the-front-end
//Forcing nickname as display_name in custom edit profile template
//http://wordpress.stackexchange.com/questions/35403/forcing-nickname-as-display-name-in-custom-edit-profile-template
///////
<?php
@fabiomontefuscolo
fabiomontefuscolo / models.py
Created January 9, 2012 19:20
Let the Django FileField overwrite files with the same name
# -*- coding: utf-8 -*-
from django.conf import settings
from django.core.files.storage import FileSystemStorage
from django.db import models
class OverwriteStorage(FileSystemStorage):
'''
Muda o comportamento padrão do Django e o faz sobrescrever arquivos de
mesmo nome que foram carregados pelo usuário ao invés de renomeá-los.
'''
@kyo-takano
kyo-takano / making-the-most-of-local-llms.ipynb
Last active May 11, 2024 13:14
ローカルLLMはこーやって使うの💢
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
// from https://kelvinzhang.com/playground/scroll-area
import { CSSProperties, useCallback, useEffect, useRef, useState } from "react";
import styled from 'styled-components';
type ScrollAreaProps = {
children: React.ReactNode;
showOverflowIndicator?: boolean;
hideScrollbar?: boolean;
indicatorColor?: CSSProperties["background"];
{
"⤡": "⤡",
"⊞": "⊞",
"×": "×",
"❮": "❮",
"❯": "❯",
"Loading...": "加载中...",
"Waiting...": "等待中...",
"In queue...": "队列中...",
"@@/^Waiting (.*)$/": "等待中 $1",
@magnetikonline
magnetikonline / README.md
Last active May 11, 2024 13:11
Modify DHCP DNS servers for Optus supplied (Vividwireless) Huawei B315 4G modem.

Modify DNS for Optus supplied Huawei B315 4G modem

The Huawei B315 modem supplied by Optus for the (now defunt) Vividwireless service is a workable but sadly rather crippled device, even down to the inability to modify assigned DNS servers from it's DHCP server away from Optus DNS to something sane (Google DNS/Cloudflare/etc.).

This script should allow for the easy update of assigned DNS servers and has been tested with Google Chrome.

Usage

  • Log into router web UI (e.g. http://192.168.0.1).
  • From the same browser session, open the "web developer tools" pane.