Skip to content

Instantly share code, notes, and snippets.

Avatar

Amit Merchant amitmerchant1990

View GitHub Profile
View konami.js
var pattern = ['ArrowUp', 'ArrowUp', 'ArrowDown', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowLeft', 'ArrowRight', 'b', 'a'];
var current = 0;
var keyHandler = function (event) {
// If the key isn't in the pattern, or isn't the current key in the pattern, reset
if (pattern.indexOf(event.key) < 0 || event.key !== pattern[current]) {
current = 0;
return;
}
@amitmerchant1990
amitmerchant1990 / stylish.css
Last active Mar 26, 2021
Revert back to good old GitHub Homepage
View stylish.css
/**
1. Install the Stylish(https://chrome.google.com/webstore/detail/stylish/fjnbnpbmkenffdnngjfgmeleoegfcffe?hl=en) extension for Chrome.
2. Open up extension options and paste the CSS mentioned below.
3. Specify the "URLs on the domain" to be `github.com`.
4. Add a title and save.
*/
.dashboard-sidebar {
float: right;
padding-right: 10px;
@amitmerchant1990
amitmerchant1990 / index.php
Created Feb 3, 2018
Validate Email (PHP)
View index.php
<?php
if(!filter_var($emailAddress, FILTER_VALIDATE_EMAIL)) {
//Email is invalid. Show the user an error message.
}
View instruction.md

Assuming you are using linux If you need to stop some application running on some specific port use this and you know the port but not the process id. find the process id like this

netstat -plten | grep LISTEN | grep 3000

this will output some thing like this

tcp        0      0 :::10060                    :::*                          LISTEN      0          20465      3489/node    
where 3489 is the process id.
@amitmerchant1990
amitmerchant1990 / find_duplicate_records.sql
Created May 31, 2017
Quickly find duplicate records based on any field
View find_duplicate_records.sql
SELECT *
FROM 2009_product_catalog
WHERE sku IN (
SELECT sku
FROM 2009_product_catalog
GROUP BY sku
HAVING count(sku) > 1
)
ORDER BY sku
@amitmerchant1990
amitmerchant1990 / remote_file_exists.php
Last active May 31, 2017
PHP : Check it remote file exists
View remote_file_exists.php
<?php
// E.g. checkRemoteFileExists('https://avatars0.githubusercontent.com/u/3647841?v=3&s=460') == true
function checkRemoteFileExists($url){
$curl = curl_init($url);
//don't fetch the actual page, you only want to check the connection is ok
curl_setopt($curl, CURLOPT_NOBODY, true);
//do request
View findings.md
View directory_structure
.
+-- hooks
+-- node_modules
+-- plugins
+-- resources
| +-- android
| +-- ios
| +-- wp8
+-- src
| +-- app
View home.ts
import { Component, ViewChild } from '@angular/core';
import { Content } from 'ionic-angular';
import { NavController } from 'ionic-angular';
import marked from 'marked';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
View home.ts
convert(this) {
if(this.toggleVal==true){
if(this.plainText && this.plainText!=''){
let plainText = this.plainText
this.markdownText = marked(plainText.toString())
this.content = this.markdownText
}else{
this.toggleVal=false
}