Skip to content

Instantly share code, notes, and snippets.

Avatar
😈
YEAH!

Pavol Fulop pfulop

😈
YEAH!
  • Rotterdam, the Netherlands
View GitHub Profile
View Shader.metal
#include <metal_stdlib>
using namespace metal;
#include <SceneKit/scn_metal>
#define GREEN_SCREEN_R 71.0/255.0
#define GREEN_SCREEN_G 255.0/255.0
#define GREEN_SCREEN_B 21.0/255.0
struct VertexInput {
float3 position [[attribute(SCNVertexSemanticPosition)]];
View shader.m
uniform vec3 c_colorToReplace;
uniform float c_thresholdSensitivity;
uniform float c_smoothing;
#pragma transparent
#pragma body
vec3 textureColor = _surface.diffuse.rgb;
float maskY = 0.2989 * c_colorToReplace.r + 0.5866 * c_colorToReplace.g + 0.1145 * c_colorToReplace.b;
@pfulop
pfulop / refresh-token.js
Last active Aug 23, 2020
how to refresh amplify token
View refresh-token.js
const refreshToken = async () => {
const refreshPromise = new Promise(async (resolve) => {
const user = await Auth.currentAuthenticatedUser();
const session = await Auth.currentSession();
user.refreshSession(session.refreshToken, async (res, newSession) => {
if (newSession) {
await Auth.currentUserCredentials();
}
resolve('ok');
@pfulop
pfulop / error-debug.vtl
Created Feb 24, 2019
Example of vtl error log
View error-debug.vtl
$util.error($util.toJson($variable), "404")
#**
Where $variable is variable to print out in response.
*#
@pfulop
pfulop / schemaexample.graphql
Created Feb 24, 2019
example appsync subscription for medium article
View schemaexample.graphql
type Subscription {
translationsSubscription: TranslationRequest
@aws_subscribe(
mutations: ["assignTranslation", "unassign", "updateTranslationState"]
)
newTranslationSubscription: TranslationRequest
@aws_subscribe(mutations: ["submitTranslationRequest"])
}
@pfulop
pfulop / updateItem.vtl
Created Jan 21, 2019
example UpdateItem with conditions
View updateItem.vtl
{
"version" : "2017-02-28",
"operation" : "UpdateItem",
"key" : {
"createdAt": $util.dynamodb.toDynamoDBJson($ctx.args.createdAt),
"translationState": $util.dynamodb.toDynamoDBJson('waiting')
},
"update" : {
"expression" : "SET #content = :content",
"expressionNames" : {
View tb_boilerplate.py
embeddings = tf.get_variable('embedding', initializer = tf.constant(vectors))
indexes = tf.get_variable('index', initializer = tf.constant(indexes))
metadata_file = '/run/media/backman/yay/ui_embs/metadata.tsv'
config = tf.contrib.tensorboard.plugins.projector.ProjectorConfig()
emb_proj = config.embeddings.add()
emb_proj.tensor_name = 'embedding'
emb_proj.sprite.image_path = 'spritesheet.png'
emb_proj.sprite.single_image_dim.extend([64,64])
emb_proj.metadata_path = metadata_file
summary_writer = tf.summary.FileWriter('/run/media/backman/yay/ui_embs/')
View MyTaskService.js
public class MyTaskService extends HeadlessJsTaskService {
@Override
protected @Nullable HeadlessJsTaskConfig getTaskConfig(Intent intent) {
return new HeadlessJsTaskConfig(
"MeasureInternetz",
null,
5000);
}
}
View NetworkChangeReceiver.java
public class NetworkChangeReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, final Intent intent) {
if(!isAppOnForeground((context))){
if(isInternet(context))
{
Intent serviceIntent = new Intent(context, MyTaskService.class);
context.startService(serviceIntent);
View manifest.xml
<receiver android:name=".NetworkChangeReceiver" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>