Skip to content

Instantly share code, notes, and snippets.

@Slavenin
Slavenin / mix.ex
Created November 2, 2023 14:28
lesson 7 snippets
defmodule Test.MixProject do
use Mix.Project
def project do
[
app: :test,
version: "0.1.0",
elixir: "~> 1.15",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
@Slavenin
Slavenin / GraphController.php
Last active February 16, 2021 12:38
class dependency graph visualization in 3d space with threejs
<?php
namespace App\Http\Controller\Graph;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\Reader;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping\ManyToMany;
use Doctrine\ORM\Mapping\ManyToOne;
@Slavenin
Slavenin / fields.ex
Last active October 20, 2022 06:52
Implementation protocol Jason.Encoder with a group of fields support
defmodule MyApp.Serializer.Fields do
defmacro __using__(fields) do
quote do
@json_group_fields unquote(fields)
def get_fields_for_group(group) do
group = MapSet.new(group)
Enum.reduce(@json_group_fields, [], fn {f, g}, acc ->
g = MapSet.new(g)
@Slavenin
Slavenin / DepsViz.js
Last active January 13, 2020 09:37
Vizualize graph of your react app dependencies like a boss
import React, { useEffect } from 'react';
import ForceGraph3D from '3d-force-graph';
import md5 from 'blueimp-md5';
import { makeStyles } from '@material-ui/core/styles';
import Close from '@material-ui/icons/Close';
import Input from '@material-ui/core/Input';
import InputAdornment from '@material-ui/core/InputAdornment';
import IconButton from '@material-ui/core/IconButton';
import SelectedTree from './Tree';
case entities do
nil ->
text
entities ->
Enum.filter(entities, fn
%{type: "text_link"} -> true
_e -> false
end)
|> Enum.reduce({0, []}, fn %{length: length, offset: offset, url: url}, {prev, acc} ->
function SignCadesBES_Async_File(certListBoxId, dataToSign, onSign, onError) {
cadesplugin.async_spawn(function* (arg) {
var e = document.getElementById(arg[ 0 ]);
var selectedCertID = e.selectedIndex;
if (selectedCertID == -1) {
alert("Select certificate");
return;
}
var certificate = global_selectbox_container[ selectedCertID ];
var Signature;
const path = require('path');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = function(env) {
const production = process.env.NODE_ENV === 'production';
return {
devtool: production ? 'source-maps' : 'eval',
entry: [
'./js/app.js',
'./css/app.css',
'./css/phoenix.css',
defmodule Behaviours.Telegram do
@moduledoc false
@callback sendInfo(accountId :: term, info :: term) :: {:ok}
end
{
"proc": {
"pid_file": "/var/run/nxs-chat-srv.pid",
"queue_worker_term_timeout": 10,
"rest_api_term_timeout": 10,
"daemonize": true
},
"logging": {
"level": 31,
"path": "/var/log/nxs-chat-srv/nxs-chat-srv.log"
import { combineReducers } from 'redux'
import { reducer as formReducer } from 'redux-form'
import { routerReducer } from 'react-router-redux'
import App from './App'
import Menu from './Menu'
import Login from './Login'
import UniList from './UniList'
import UniForm from './UniForm'