Skip to content

Instantly share code, notes, and snippets.

View dsignr's full-sized avatar

Neya dsignr

View GitHub Profile
@dsignr
dsignr / form_live.ex
Created April 9, 2025 08:41 — forked from LostKobrakai/form_live.ex
Phoenix LiveView form with nested embeds and add/delete buttons
defmodule NestedWeb.FormLive do
use NestedWeb, :live_view
require Logger
defmodule Form do
use Ecto.Schema
import Ecto.Changeset
embedded_schema do
field :name, :string
@dsignr
dsignr / ai_image.ex
Created January 12, 2025 08:09
AI Image generator Snippet
defmodule AI.ImageGen do
image_prompt_generator_prompt = """
[INST] <<SYS>>
You are an expert recipe image designer.
Your job is to generate a prompt for DALL-E image generator to generate a cover image for an E-Commerce product based on a user's given question.
Step 1: Extract the key information from the question.
Step 2: Generate a prompt for DALL-E image generator to generate a cover image for an E-Commerce product based on the extracted information.
GUIDELINES:
1. The images should be free of text or artifacts and must be stylish, modern, futuristic and vivid.
2. Do not create any hues in the produced image. Go with a black background if you are unsure.
@dsignr
dsignr / gist:ca821c6ee683efeb50897abaf2a641a2
Created May 27, 2024 18:50
Windows 7 All Online/Offline [Retail-MAK] Activation Keys
Windows 7 All Online/Offline [Retail-MAK] Activation Keys
=================================================================================
. Run "Command Prompt" as Administrator
. slmgr.vbs -ipk Product Key
. slui4
=================================================================================
Windows 7 Ultimate Retail Phone Activation Keys
RHTBY-VWY6D-QJRJ9-JGQ3X-Q2289
V77DJ-CT8WB-Y3GXT-X3FBP-6F987
JC7BV-94FD2-D86PH-XRMHR-BXKDG
@dsignr
dsignr / frontmatter.ex
Created June 26, 2019 20:17
Parse frontmatter in Elixir
def extract(changeset) do
file_name = changeset.data.name
data = File.read!("#{@data_folder}/pages/#{file_name}")
case String.split(data, ~r/\n-{3,}\n/, parts: 2) do
[""] ->
%{frontmatter: nil, content: nil}
[frontmatter, content] ->
%{
frontmatter: parse_yaml(frontmatter),
content: content
@dsignr
dsignr / dynamic_access.ex
Created September 5, 2018 08:57
Dynamic way to access an element's attributes in Elixir
defp find_in_combinations(combinations, element) do
Enum.reduce(combinations, [], fn(c, acc) ->
# A dynamic way to access c.element (Eg. c.engine)
if Map.get(c, element) do
acc ++ [Map.get(c, element)]
else
acc
end
end)
end
@dsignr
dsignr / install.md
Last active August 12, 2018 23:26 — forked from filipelinhares/install.md
Install Erlang, Elixir and Phoenix - Ubuntu and OSX

Install Erlang, Elixir and Phoenix

Ubuntu

Erlang

sudo apt-get install erlang

Elixir

@dsignr
dsignr / tutorial.md
Created July 17, 2018 15:24 — forked from swalkinshaw/tutorial.md
Designing a GraphQL API

Tutorial: Designing a GraphQL API

This tutorial was created by Shopify for internal purposes. We've created a public version of it since we think it's useful to anyone creating a GraphQL API.

It's based on lessons learned from creating and evolving production schemas at Shopify over almost 3 years. The tutorial has evolved and will continue to change in the future so nothing is set in stone.

@dsignr
dsignr / example.ex
Created June 3, 2018 07:53
Sample Elixir code
defmodule AppName.IpnController do
@moduledoc """
IPN Controller.
"""
use AppName.Web, :controller
def create(conn, params) do
# PayPal requires the params returned in the exact order given.
# The map needs to be a list. encode/1 keep the order of a list,
@dsignr
dsignr / example.py
Created June 3, 2018 07:52
Sample Python syntax example
# -*- coding: utf-8 -*-
"""
flask.globals
~~~~~~~~~~~~~
Defines all the global objects that are proxies to the current
active context.
:copyright: © 2010 by the Pallets team.
:license: BSD, see LICENSE for more details.
"""
@dsignr
dsignr / example.rb
Created June 3, 2018 07:48
Ruby syntax example
class DriveAPI
include HTTParty
base_uri 'https://www.googleapis.com'
#for debugging
debug_output $stdout
end
def create_file(file_name, parent_id)
check_token!
access_token = current_user.access_token