Skip to content

Instantly share code, notes, and snippets.

View Harshit369's full-sized avatar
💻
Committing out there if not here.

Harshit Thukral Harshit369

💻
Committing out there if not here.
View GitHub Profile
@scottpersinger
scottpersinger / images.py
Created September 8, 2024 03:39
Doing image analysis with LangChain agents
# Got inspiration from here: https://github.com/langchain-ai/langchain/discussions/20820
human = HumanMessagePromptTemplate.from_template(
template=[
{"type": "text", "text": "{input}"},
{
"type": "image_url",
"image_url": "{encoded_image_url}",
},
]
@dabit3
dabit3 / SubscriptionHook.js
Last active January 26, 2021 16:04
Example of using custom React hooks for managing GraphQL subscriptions
import { useEffect, useState } from 'react'
import { API, graphqlOperation } from 'aws-amplify'
const ListTalks = `
query {
listTalks {
items {
name
description
presenter {
@willhoney7
willhoney7 / play_pause_youtube
Created September 6, 2018 17:45
play/pause youtube via applescript
tell application "Google Chrome"
set found_video to false
set window_list to every window
repeat with the_window in window_list
if found_video is equal to true then
exit repeat
end if
set tab_list to every tab in the_window
repeat with the_tab in tab_list
if the title of the_tab contains "- YouTube" then
@rafaellucio
rafaellucio / README.md
Last active August 14, 2024 17:33
Plugin NVM oh-my-zsh

NVM plugin

Description

This plugin provides load nvm if it exists and when the .nvmrc file exists in your directory, it will download the described node version.

To start using it:

  • Add the ZSH_NVM_AUTOLOAD=true at the beginning of the file ~/.zshrc
  • Add nvm plugin to your plugins array in ~/.zshrc
@fokusferit
fokusferit / enzyme_render_diffs.md
Last active September 19, 2025 19:40
Difference between Shallow, Mount and render of Enzyme

Shallow

Real unit test (isolation, no children render)

Simple shallow

Calls:

  • constructor
  • render
@saulshanabrook
saulshanabrook / README.md
Created October 19, 2016 14:20
Saving Web Crypto Keys using indexedDB

This is a working example on how to store CryptoKeys locally in your browser. We are able to save the objects, without serializing them. This means we can keep them not exportable (which might be more secure?? not sure what attack vectors this prevents).

To try out this example, first make sure you are in a browser that has support for async...await and indexedDB (latest chrome canary with chrome://flags "Enable Experimental Javascript" works). Load some page and copy and paste this code into the console. Then call encryptDataSaveKey(). This will create a private/public key pair and encrypted some random data with the private key. Then save both of them. Now reload the page, copy in the code, and run loadKeyDecryptData(). It will load the keys and encrypted data and decrypt it. You should see the same data logged both times.

@mmazzarolo
mmazzarolo / mobxLogger.js
Created May 30, 2016 13:10
While waiting for React-Native MobX devtools...
import mobx from 'mobx'
const DEFAULT_STYLE = 'color: #006d92; font-weight:bold;'
// Just call this function after MobX initialization
// As argument you can pass an object with:
// - collapsed: true -> shows the log collapsed
// - style -> the style applied to the action description
export const startLogging = ({ collapsed, style } = {}) => {
mobx.spy(event => {
@tribou
tribou / TodoStore.js
Last active September 12, 2018 16:12
A sample Flux store in ES6
// Todo store
//
// Requiring the Dispatcher, Constants, and
// event emitter dependencies
import AppDispatcher from '../dispatcher/AppDispatcher';
import { TodoConstants } from '../constants/TodoConstants';
import { EventEmitter } from 'events';
const CHANGE_EVENT = 'change';
@mikaelbr
mikaelbr / destructuring.js
Last active September 5, 2025 11:19
Complete collection of JavaScript destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
@lemiorhan
lemiorhan / post-receive
Last active October 13, 2025 02:29
Post-receive hook to deploy the code being pushed to production branch to a specific folder
#!/bin/bash
target_branch="production"
working_tree="PATH_TO_DEPLOY"
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ -n "$branch" ] && [ "$target_branch" == "$branch" ]; then