Skip to content

Instantly share code, notes, and snippets.

View pfulop's full-sized avatar
😈
YEAH!

Pavol Fulop pfulop

😈
YEAH!
  • Trondheim, Norway
View GitHub Profile
#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)]];
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 August 23, 2020 16:41
how to refresh amplify token
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 February 24, 2019 09:51
Example of vtl error log
$util.error($util.toJson($variable), "404")
#**
Where $variable is variable to print out in response.
*#
@pfulop
pfulop / schemaexample.graphql
Created February 24, 2019 09:25
example appsync subscription for medium article
type Subscription {
translationsSubscription: TranslationRequest
@aws_subscribe(
mutations: ["assignTranslation", "unassign", "updateTranslationState"]
)
newTranslationSubscription: TranslationRequest
@aws_subscribe(mutations: ["submitTranslationRequest"])
}
@pfulop
pfulop / updateItem.vtl
Created January 21, 2019 21:01
example UpdateItem with conditions
{
"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" : {
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/')
public class MyTaskService extends HeadlessJsTaskService {
@Override
protected @Nullable HeadlessJsTaskConfig getTaskConfig(Intent intent) {
return new HeadlessJsTaskConfig(
"MeasureInternetz",
null,
5000);
}
}
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);
<receiver android:name=".NetworkChangeReceiver" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>