This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Convert a string to a URL slug | |
* @param {string} str - The string to be slugified. | |
* @returns {string} The slugified string. | |
*/ | |
function toSlug(str) { | |
str = str.replace(/^\s+|\s+$/g, ""); // trim | |
str = str.toLowerCase(); | |
// remove accents, swap ñ for n, etc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Console\Commands; | |
use Illuminate\Console\Command; | |
use Illuminate\Support\Composer; | |
use Symfony\Component\Finder\Finder; | |
use Illuminate\Filesystem\Filesystem; | |
use Symfony\Component\Console\Input\InputArgument; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* It binds the function to the class instance. | |
*/ | |
function AutoBind(_: any, __: string, descriptor: PropertyDescriptor) { | |
const originalMethod = descriptor.value | |
const adjustedDescriptor: PropertyDescriptor = { | |
configurable: true, | |
enumerable: false, | |
get() { | |
const boundFunction = originalMethod.bind(this) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"TSX Function Component for React Web": { | |
"prefix": "cmp-web", | |
"body": [ | |
"interface $1Props {}\n", | |
"export default function $1(props: $1Props) {", | |
"\treturn (", | |
"\t\t<div>", | |
"\t\t\t<p>$1</p>", | |
"\t\t</div>", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#undef max | |
struct Node_AVL | |
{ | |
int value; | |
int height; | |
struct Node_AVL *left, *right; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.querySelectorAll('[value="Setuju"]').forEach((setuju) => (setuju.checked = true)); | |
document.getElementById("securityCode").scrollIntoView(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Calculate the height of an image based on its aspect ratio and width | |
* @param {number} width | |
* @param {number} ratioWidth | |
* @param {number} ratioHeight | |
* @returns the calculated height | |
*/ | |
function getHeight(width, ratioWidth, ratioHeight) { | |
const ratio = width / ratioWidth; | |
const height = ratio * ratioHeight; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JavaScript Code Snippet | |
// Convert integer to Rupiah & vice versa | |
// https://gist.github.com/845309 | |
// | |
// Copyright 2011-2012, Faisalman | |
// Licensed under The MIT License | |
// http://www.opensource.org/licenses/mit-license | |
/** | |
* Convert a number to a string of its equivalent in rupiah |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import twitter, re, datetime, pandas as pd | |
class Twitter_Miner(): | |
request_limit = 20 | |
api = False | |
data = [] | |
twitter_keys = { | |
'consumer_key': '', | |
'consumer_secret': '', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tweepy | |
import csv | |
# input your credentials here | |
consumer_key = '' | |
consumer_secret = '' | |
access_token = '' | |
access_token_secret = '' | |
auth = tweepy.OAuthHandler(consumer_key, consumer_secret) |
OlderNewer