Skip to content

Instantly share code, notes, and snippets.

View codeeshop-oc's full-sized avatar
🎯
Focusing

Anant Negi codeeshop-oc

🎯
Focusing
View GitHub Profile
@codeeshop-oc
codeeshop-oc / curl-request.php
Last active February 3, 2022 11:53
PHP Function - Curl Request for Generating Previews
function curl_get($url, array $options = array())
{
$defaults = array(
CURLOPT_URL => $url,
CURLOPT_HEADER => TRUE,
CURLOPT_FOLLOWLOCATION => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_BINARYTRANSFER => TRUE,
CURLOPT_AUTOREFERER => TRUE,
CURLOPT_SSL_VERIFYPEER => FALSE,
@codeeshop-oc
codeeshop-oc / replace-code.php
Created July 4, 2021 09:06
Replacing Unwanted Characters
private function replaceExtraCode($text = '') {
return html_entity_decode(str_replace([''', ''', '''], ['\''], $text));
}
@codeeshop-oc
codeeshop-oc / link-preview.php
Last active February 3, 2022 11:52
Generating Previews with PHP
@codeeshop-oc
codeeshop-oc / preview-db.sql
Created July 4, 2021 09:24
Preview Save Database
DROP TABLE IF EXISTS `preview`;
CREATE TABLE `tbl_preview` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`url` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
`json_data` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
`createdDtm` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE current_timestamp(),
`updatedDtm` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
private function getLinkData($meta_tags = []) {
$title = $description = $image = $url = $domain = $youtube_id = '';
if(!empty($meta_tags)) {
$url = ($meta_tags['url']);
$sourceUrl = parse_url($url);
try {
default_branch=$(git rev-parse --abbrev-ref HEAD)
read -p "Enter your [Default - $default_branch]: " name
name=${name:-$default_branch}
git checkout -b $name
git add . && \
# git reset -- ".env"
git reset -- ".php-cs-fixer.cache"
read -p "Commit description: " desc
git commit -m "$desc" --no-verify && \
git push -u origin $name
/*
Using https://gist.github.com/paulmillr/4524946#file-github-users-stats-json
all -- JSON Data from above Gist to get All Followers
Found Least Follow Count
*/
let leastFollow = 100000000
all.map(v => {
if (v.followers > 0 && v.followers < leastFollow) {
leastFollow = v.followers
}
@codeeshop-oc
codeeshop-oc / string_prototype_convert_text.js
Last active February 3, 2022 12:01
Ellipsis Text and add `anchor tag` to URL
/* Ellipsis Text and add `anchor tag` to URL */
String.prototype.convertText = function (ellipse = 0, suffix = '...') {
if (!this.length) return;
let urlRegex = /(((https?:\/\/)|(www\.))[^\s]+)/g;
this.replace(urlRegex, function (url) {
let hyperlink = url;
if (!hyperlink.match('^https?:\/\/')) {
hyperlink = 'http://' + hyperlink;
}
@codeeshop-oc
codeeshop-oc / git-queries.txt
Created February 7, 2022 09:50
Git Important Queries
Find Stars
https://github.com/search?p=3&q=stars%3A%3E100000&type=Repositories