Skip to content

Instantly share code, notes, and snippets.

View goravsingal's full-sized avatar
🐢
Exploring, whats new?

Gorav Singal goravsingal

🐢
Exploring, whats new?
View GitHub Profile
export class KydsService {
/**
* Everytime a test score is uploaded, or some accident or challan is there for a driver,
* this method refreshes driver's KYD score
*/
async refreshKydScore(userId: User['id']) {
// fetch user
const user: User | null = await this.userService.findById(userId);
if (!user) {
throw new BadRequestException('No such user');
@goravsingal
goravsingal / patch.diff
Created February 26, 2021 12:40
Patch for Python-3.7.9 for FIPS enabled Openssl
diff -aur Python-3.7.9__orig/Lib/hashlib.py Python-3.7.9/Lib/hashlib.py
--- Python-3.7.9__orig/Lib/hashlib.py 2020-08-15 05:20:16.000000000 +0000
+++ Python-3.7.9/Lib/hashlib.py 2021-02-26 07:25:23.295243000 +0000
@@ -124,7 +124,11 @@
f()
# Use the C function directly (very fast)
return f
- except (AttributeError, ValueError):
+ except AttributeError:
+ return __get_builtin_constructor(name)
{# https://www.gyanblog.com/gyan/bootstrap-sticky-is-not-sticky-drupal/ #}
{# Before removing #}
{%
set classes = [
'region',
'region-' ~ region|clean_class,
]
%}
{% if content %}
<div{{ attributes.addClass(classes) }}>
@goravsingal
goravsingal / nodesRequiredModification.php
Created August 19, 2017 11:22
To get all the nodes of a specific type, which doesn't have image sources from my specific domain
/**
* See if a drupal node has images within my domain or not
**/
function requireModification($nid) {
$nd = node_load($nid);
//read body of node
$body = $nd->body['und'][0]['value'];
$doc = new DOMDocument();
@goravsingal
goravsingal / fetchImages.php
Created August 19, 2017 11:06
To get all the image tags from an html
$body = '...html...';
$doc = new DOMDocument();
$doc->loadHTML($body);
$tags = $doc->getElementsByTagName('img');
$imgArr = array();
//iterate over all image tags
foreach ($tags as $tag) {
//get src attribute of an img tag
@goravsingal
goravsingal / elasticsearch_array_filter.js
Created August 2, 2017 09:25
Calculate unique elements from two arrays, in javascript
//example of an object
const exampleResult = {
"_index": "test_index",
"_type": "test_type",
"_id": "4",
"_score": 1,
"_source": {
"name": "name4",
"createdAt": "2017-07-27T08:38:48.276Z"
}
@goravsingal
goravsingal / letsencrypt2.log
Created July 22, 2017 11:43
Letsencrypt certificate with cloudflare
sudo /usr/bin/certbot certonly -d example.com -d www.example.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log
How would you like to authenticate with the ACME CA?
-------------------------------------------------------------------------------
1: Apache Web Server plugin - Beta (apache)
2: Place files in webroot directory (webroot)
3: Spin up a temporary webserver (standalone)
-------------------------------------------------------------------------------
Select the appropriate number [1-3] then [enter] (press 'c' to cancel): 2
@goravsingal
goravsingal / letsencrypt.log
Created July 22, 2017 11:22
Letsencrypt certificate renew issues while your website is using cloudflare
Encountered vhost ambiguity but unable to ask for user guidance in non-interactive mode.
Currently Certbot needs each vhost to be in its own conf file, and may need vhosts to be explicitly
labelled with ServerName or ServerAlias directories.
Falling back to default vhost *:443...
Encountered vhost ambiguity but unable to ask for user guidance in non-interactive mode.
Currently Certbot needs each vhost to be in its own conf file, and may need vhosts to be explicitly
labelled with ServerName or ServerAlias directories.
@goravsingal
goravsingal / gist:9003bb3cf60b269d6e45e39e415f1804
Last active April 11, 2018 11:11
Linkage Error: Loader constraint violation - gyanblog.com
java.lang.LinkageError: loader constraint violation: loader (instance of org/powermock/core/classloader/MockClassLoader) previously initiated loading for a different type with name "javax/management/MBeanServer"
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.lang.ClassLoader.defineClass(ClassLoader.java:642)
at org.powermock.core.classloader.MockClassLoader.loadUnmockedClass(MockClassLoader.java:236)
at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:181)
at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:70)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at com.amazonaws.jmx.MBeans.registerMBean(MBeans.java:52)
at com.amazonaws.jmx.SdkMBeanRegistrySupport.registerMetricAdminMBean(SdkMBeanRegistrySupport.java:27)