This file contains hidden or 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
// TRPC API endpoint | |
// src/app/api/trpc/[trpc]/route.ts | |
import { fetchRequestHandler } from "@trpc/server/adapters/fetch"; | |
import { type NextRequest } from "next/server"; | |
import { env } from "~/env"; | |
import { appRouter } from "~/server/api/root"; | |
import { createTRPCContext } from "~/server/api/trpc"; | |
import { getAuth } from "@clerk/nextjs/server"; |
This file contains hidden or 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
// LinkedIn recruiter search results highlighter. | |
// Paste into your browser's JavaScript console. | |
// | |
// Features: | |
// - Auto-expand experience items | |
// - Color experience items based on duration (red if less than 1 year, green if 2y+, etc) | |
// - Strike-through experience items containing certain keywords | |
// - Record profiles already seen in search results and hide them in subsequent searches (to enable, set config variable to true below) | |
// | |
// If you make improvements, feel free to reach out and I can merge them. <aurelien.gasser at gmail.com> |
This file contains hidden or 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 { PrismaClient } from '@prisma/client' | |
const dbClient = new PrismaClient({}) | |
/* | |
* Middleware to replace hard deletes with soft deletes | |
* 1. deletes will update deletedAt column | |
* 2. finds and updates will filter out deletedAt rows | |
*/ | |
dbClient.$use(async (params, next) => { |
This file contains hidden or 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
# Keras tokenizer lacks serialization. Therefore I created the below to address this without changing the API. | |
# (Since I don't know how long it'll take for keras to support it) | |
# The Tokenizer __init__ should be modified to take the word_stats dictionary as a kwarg, | |
# and a method added to the class to return the stats | |
# Expiermentally this works, but I am not sure of any nuances in the Tokenizer class. | |
def test_tokenizer(): | |
texts = ["It was the best of times, it was the worst of times, it was the age of wisdom", | |
"it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, ", | |
"it was the season of Light, it was the season of Darkness, it was the spring of hope, ", |
This file contains hidden or 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
class AttentionWithContext(Layer): | |
""" | |
Attention operation, with a context/query vector, for temporal data. | |
Supports Masking. | |
Follows the work of Yang et al. [https://www.cs.cmu.edu/~diyiy/docs/naacl16.pdf] | |
"Hierarchical Attention Networks for Document Classification" | |
by using a context vector to assist the attention | |
# Input shape | |
3D tensor with shape: `(samples, steps, features)`. | |
# Output shape |
This file contains hidden or 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
def dot_product(x, kernel): | |
""" | |
Wrapper for dot product operation, in order to be compatible with both | |
Theano and Tensorflow | |
Args: | |
x (): input | |
kernel (): weights | |
Returns: | |
""" | |
if K.backend() == 'tensorflow': |
This file contains hidden or 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
from keras import backend as K, initializers, regularizers, constraints | |
from keras.engine.topology import Layer | |
def dot_product(x, kernel): | |
""" | |
Wrapper for dot product operation, in order to be compatible with both | |
Theano and Tensorflow | |
Args: |
This file contains hidden or 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 "TSTapstream.h" | |
#define MIXPANEL_TOKEN @"YOUR_MIXPANEL_TOKEN" | |
// ... | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
[Mixpanel sharedInstanceWithToken:MIXPANEL_TOKEN]; | |
This file contains hidden or 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
class MixPanel(object): | |
def get_page_view_funnel(self, content_urls): | |
# Build up the events array. Each "event" is a step in the funnel | |
events = [] | |
for cu in content_urls: | |
events.append({ | |
"event": "Page View", | |
"selector": 'properties["Page View Page"] == "%s"' % (cu,), | |
}) |