1675394520
More details
I started ts-prune to find a sustainable way to detect unused exports in Typescript code. Due to the absence of native APIs that enable this, the best way forward was to consolidate a few hacks together that did this semi-elegantly for most usecases.
However, due to the popularity of ts-prune, it has absorbed more use cases, and complexity has bloated to the point that I'm no longer comfortable to add more features or do any other changes to the core system.
The most important thing for ts-prune is to be backwards compatible and reliable for existing use cases.
Find potentially unused exports in your Typescript project with zero configuration.
ts-prune
exposes a cli that reads your tsconfig file and prints out all the unused exports in your source files.
Install ts-prune with yarn or npm
# npm
npm install ts-prune --save-dev
# yarn
yarn add -D ts-prune
You can install it in your project and alias it to a npm script in package.json.
{
"scripts": {
"find-deadcode": "ts-prune"
}
}
If you want to run against different Typescript configuration than tsconfig.json:
ts-prune -p tsconfig.dev.json
ts-prune supports CLI and file configuration via cosmiconfig (all file formats are supported).
-p, --project
- tsconfig.json path(tsconfig.json
by default)-i, --ignore
- errors ignore RegExp pattern-e, --error
- return error code if unused exports are found-s, --skip
- skip these files when determining whether code is used. (For example, .test.ts?
will stop ts-prune from considering an export in test file usages)CLI configuration options:
ts-prune -p my-tsconfig.json -i my-component-ignore-patterns?
Configuration file example .ts-prunerc
:
{
"ignore": "my-component-ignore-patterns?"
}
ts-prune | wc -l
You can either,
1. Use the -i, --ignore
configuration option:
ts-prune --ignore 'src/ignore-this-path'
2. Use grep -v
to filter the output:
ts-prune | grep -v src/ignore-this-path
You can either,
1. Use the -i, --ignore
configuration option:
ts-prune --ignore 'src/ignore-this-path|src/also-ignore-this-path'
2. Use multiple grep -v
to filter the output:
ts-prune | grep -v src/ignore-this-path | grep -v src/also-ignore-this-path
You can either,
1. Prefix the export with // ts-prune-ignore-next
// ts-prune-ignore-next
export const thisNeedsIgnoring = foo;
2. Use grep -v
to ignore a more widely used export name
ts-prune | grep -v ignoreThisThroughoutMyCodebase
Author: nadeesha
Source Code: https://github.com/nadeesha/ts-prune
1664818560
A simple library, which makes the use of OpenGL a little bit more convenient and Julian. If you have any questions, please open an issue.
There are some tutorials and examples.
Buffers
and Texture
objects are wrapped, with best support for arrays of FixedSizeArrays, Colors and Reals.Buffers
and Textures
, offering functions like push!
, getindex
, setindex!
, etc for GPU arrays, just like you're used to from Julia Arrays.using ModernGL, GeometryTypes, GLAbstraction, GLFW
const GLA = GLAbstraction
window = GLFW.Window(name="Drawing polygons 5", resolution=(800,600))
GLA.set_context!(window)
vertex_shader = GLA.vert"""
#version 150
in vec2 position;
in vec3 color;
out vec3 Color;
void main()
{
Color = color;
gl_Position = vec4(position, 0.0, 1.0);
}
"""
fragment_shader = GLA.frag"""
# version 150
in vec3 Color;
out vec4 outColor;
void main()
{
outColor = vec4(Color, 1.0);
}
"""
prog = GLA.Program(vertex_shader, fragment_shader)
vertex_positions = Point{2,Float32}[(-0.5, 0.5),
( 0.5, 0.5),
( 0.5, -0.5),
(-0.5, -0.5)]
vertex_colors = Vec3f0[(1, 0, 0),
(0, 1, 0),
(0, 0, 1),
(1, 1, 1)]
elements = Face{3,UInt32}[(0,1,2),
(2,3,0)]
buffers = GLA.generate_buffers(prog, position = vertex_positions, color = vertex_colors)
vao = GLA.VertexArray(buffers, elements)
glClearColor(0, 0, 0, 1)
while !GLFW.WindowShouldClose(window)
glClear(GL_COLOR_BUFFER_BIT)
GLA.bind(prog)
GLA.bind(vao)
GLA.draw(vao)
GLA.unbind(vao) #optional in this case
GLA.unbind(prog) #optional in this case
GLFW.SwapBuffers(window)
GLFW.PollEvents()
if GLFW.GetKey(window, GLFW.KEY_ESCAPE) == GLFW.PRESS
GLFW.SetWindowShouldClose(window, true)
end
end
GLFW.DestroyWindow(window) # needed if you're running this from the REPL
Credits
Thanks for all the great contributions
Author: JuliaGL
Source Code: https://github.com/JuliaGL/GLAbstraction.jl
License: View license
1664217000
This is a simple utility of defining structs by specifying types, default values and value constraints for fields, with an automatically defined user-friendly constructor. This code is extracted from Mocha.jl and MXNet.jl.
This utility is useful to define structs holding specifications or hyperparameters. The following is an example of specifications of a stochastic gradient descent optimizer used in MXNet.jl:
@defstruct SGDOptions <: AbstractOptimizerOptions (
(lr :: Real = 0.01, lr > 0),
(momentum :: Real = 0.0, momentum >= 0),
(grad_clip :: Real = 0, grad_clip >= 0),
(weight_decay :: Real = 0.0001, weight_decay >= 0),
lr_scheduler :: Any = nothing,
momentum_scheduler :: Any = nothing
)
And this is an example of the definition of a Dropout layer in Mocha.jl:
@defstruct DropoutLayer <: Layer (
name :: AbstractString = "dropout",
auto_scale :: Bool = true,
(ratio :: AbstractFloat = 0.5, 0 < ratio < 1),
(bottoms :: Vector{Symbol} = Symbol[], length(bottoms) == 1),
)
The main utilities provided by this package are two macros: @defstruct
and @defimmutable
. They are almost the same, except that the latter defines a type that is immutable. The macros can be called in the following way
@defstruct StructName (
field_name :: field_type,
(fname2 :: ftype2 = default_val2, fname2 > 0 && fname2 < 5),
(fname3 :: ftype3 = default_val3, fname3 <= fname2),
)
The StructName
can be StructName <: SuperTypeName
if the struct needs to be a subtype of SuperTypeName
. Each field should have
convert
explicitly on the user supplied values. So there is no frustration about Julia types being not covariant. For example, for a field of type Vector{AbstractString}
, it is OK if user call with ["foo", "bar"]
, which will be of type Vector{ASCIIString}
.AssertionError
will be thrown if the user does not provide a value for this field.fname3
can use the value for fname2
and safely assume the constraints for fname2
is already satisfied.A constructor will be automatically defined, where each argument should be provided as keyword arguments:
struct = StructName(field_name=7, fname3=8)
Please see the unit tests for more examples.
Author: Pluskid
Source Code: https://github.com/pluskid/SimpleStructs.jl
License: View license
1663598480
In today's post we will learn about 6 Popular Golang Libraries for Utility/Miscellaneous.
What is Utility?
Utility refers to the comprehensive benefits obtained from consuming an item or service. This sums up the utility definition. Consumers would typically aim to maximise their utility based on rational choice based on economic models. To comprehend the monetary value of an item or service is crucial because it directly impacts demand, and hence pricing, for that service or product. It is impossible to assess and quantify a consumer's utility in practice.
However, some analysts say that they may infer the value of an economic commodity or service by utilising multiple models.
Table of contents:
Functions to get fixed width of the character or string.
Provides functions to get fixed width of the character or string.
runewidth.StringWidth("つのだ☆HIRO") == 12
Zero-width character detection and removal for Go.
go get github.com/trubitsyn/go-zero-width
package main
import (
"github.com/trubitsyn/go-zero-width"
"fmt"
)
func main() {
login := "abcdef" // zero-width space between "c" and "d"
clean := zerowidth.RemoveZeroWidthCharacters(login) // a b c d e f
fmt.Printf("% x\n", login) // 61 62 63 e2 80 8b 64 65 66
fmt.Printf("% x\n", clean) // 61 62 63 64 65 66
}
go get -t github.com/trubitsyn/go-zero-width
go test github.com/trubitsyn/go-zero-width
Common case conversions covering common initialisms.
go get "github.com/codemodus/kace"
Package kace provides common case conversion functions which take into consideration common initialisms.
func Camel(s string) string
func Kebab(s string) string
func KebabUpper(s string) string
func Pascal(s string) string
func Snake(s string) string
func SnakeUpper(s string) string
type Kace
func New(initialisms map[string]bool) (*Kace, error)
func (k *Kace) Camel(s string) string
func (k *Kace) Kebab(s string) string
func (k *Kace) KebabUpper(s string) string
func (k *Kace) Pascal(s string) string
func (k *Kace) Snake(s string) string
func (k *Kace) SnakeUpper(s string) string
import (
"fmt"
"github.com/codemodus/kace"
)
func main() {
s := "this is a test sql."
fmt.Println(kace.Camel(s))
fmt.Println(kace.Pascal(s))
fmt.Println(kace.Snake(s))
fmt.Println(kace.SnakeUpper(s))
fmt.Println(kace.Kebab(s))
fmt.Println(kace.KebabUpper(s))
customInitialisms := map[string]bool{
"THIS": true,
}
k, err := kace.New(customInitialisms)
if err != nil {
// handle error
}
fmt.Println(k.Camel(s))
fmt.Println(k.Pascal(s))
fmt.Println(k.Snake(s))
fmt.Println(k.SnakeUpper(s))
fmt.Println(k.Kebab(s))
fmt.Println(k.KebabUpper(s))
// Output:
// thisIsATestSQL
// ThisIsATestSQL
// this_is_a_test_sql
// THIS_IS_A_TEST_SQL
// this-is-a-test-sql
// THIS-IS-A-TEST-SQL
// thisIsATestSql
// THISIsATestSql
// this_is_a_test_sql
// THIS_IS_A_TEST_SQL
// this-is-a-test-sql
// THIS-IS-A-TEST-SQL
}
Petrovich is the library which inflects Russian names to given grammatical case.
go get github.com/striker2000/petrovich
All functions takes three arguments: name in nominative case, gender and grammatical case.
import "github.com/striker2000/petrovich"
n := petrovich.FirstName("Кузьма", petrovich.Male, petrovich.Genitive)
fmt.Print(n) // "Кузьмы"
n = petrovich.MiddleName("Сергеевич", petrovich.Male, petrovich.Instrumental)
fmt.Print(n) // "Сергеевичем"
n = petrovich.LastName("Петров-Водкин", petrovich.Male, petrovich.Prepositional)
fmt.Print(n) // "Петрове-Водкине"
Valid values for gender are petrovich.Androgynous
, petrovich.Male
and petrovich.Female
.
Fast string sorting algorithm.
This is an optimized sorting algorithm equivalent to sort.Strings
in the Go standard library. For string sorting, a carefully implemented radix sort can be considerably faster than Quicksort, sometimes more than twice as fast.
A discussion of MSD radix sort, its implementation and a comparison with other well-known sorting algorithms can be found in Implementing radixsort. In summary, MSD radix sort uses O(n) extra space and runs in O(n+B) worst-case time, where n is the number of strings to be sorted and B is the number of bytes that must be inspected to sort the strings.
Once you have installed Go, run the go get
command to install the radix
package:
go get github.com/yourbasic/radix
Alternative suggestions with respect to keyboard layouts.
TySug is collection of packages, together they form a keyboard layout aware alternative word suggester. It can be used as both a library and a webservice.
The primary supported use-case is to help with spelling mistakes against short popular word lists (e.g. domain names). Which is useful in helping to prevent typos in e.g. e-mail addresses, detect spam, phishing (Typosquatting), etc.
The goal is to provide an extensible library that helps with finding possible spelling errors. You can use it out-of-the-box as a library, a webservice or as a set of packages to build your own application.
Currently, it's a fairly naive approach and not (yet) backed by ML.
Using TySug
You can use TySug as stand-alone webservice to match against a known-list. If you have Docker you'll have it up and running in a few minutes.
If you have Docker installed, and you quickly want to tinker, just run:
docker run --rm -it dynom/tysug:latest
If you don't have Docker, you can download the binary from the releases page.
In a different terminal, run:
curl -s "http://127.0.0.1:1337/list/domains" --data-binary '{"input": "gmail.co"}'
curl -s "http://host:port/list/domains" --data-binary '{"input": "gmail.co"}' | jq .
{
"result": "gmail.com",
"score": 0.9777777777777777,
"exact_match": false
}
The name corresponds with a list definition in the config.toml. Using this approach the service can be used for various types of data. This is both for efficiency (shorter lists to iterate over) and to be more opinionated. when no list by that name is found, a 404 is returned.
Thank you for following this article.
Golang Web Frameworks You MUST Learn
1662398640
Various utility functions for Julia.
Read more about them using the ?function
syntax (after the package has been installed and imported).
This is NOT (yet) a Julia registered package:
] add https://github.com/sylvaticus/LAJuliaUtils.jl.git
using LAJuliaUtils
Provided functions:
addCols!(df, colsName, colsType)
- Adds to the DataFrame empty column(s) colsName of type(s) colsTypecustomSort!(df, sortops)
- Sort a DataFrame by multiple cols, each specifying sort direction and custom sort orderfindall(pattern,string,caseSensitive=true)
- Find all the occurrences of pattern
in string
pivot(df::AbstractDataFrame, rowFields, colField, valuesField; <kwd args>)
- Pivot and optionally filter and sort in a single functiontoDict(df, dimCols, valueCol)
- Convert a DataFrame in a dictionary, specifying the dimensions to be used as key and the one to be used as value.unzip(unzip(file,exdir="")
- Unzip a zipped archive using ZipFileaddIfNeeded(pkgs...)
- Add (if needed) the packages in the argument list (given as strings)installAndUse(pkgs...)
- Add (if needed) and use the packages in the argument list (given as strings)Julia 0.6 only:
toDataFrame(t)
- (Julia 0.6 only) Convert an IndexedTable NDSparse table to a DataFrame, maintaining column types and (eventual) column names.defEmptyIT(dimNames, dimTypes; <kwd args>)
- (Julia 0.6 only) Define empty IndexedTable(s) with the specific dimension(s) and type(s).defVars(vars, df, dimensions;<kwd args>)
- (Julia 0.6 only) Create the required IndexedTables from a common DataFrame while specifing the dimensional columns.fillMissings!(vars, value, dimensions)
- (Julia 0.6 only) For each values in the specified dimensions, fill the values of IndexedTable(s) without a corresponding key.Author: Sylvaticus
Source Code: https://github.com/sylvaticus/LAJuliaUtils.jl
License: MIT license
1662100800
A Dart package to generate, validate and format Brazilian's CPF in an easy way.
You can validate data in a TextField
, or even format it without any effort, inside a Flutter application.
Also, you can generate valid CPFs, for testing purposes.
void main() {
final cpf = CPFUtil();
// This will generate 100 valid CPF
for (int i = 0; i < 100; i++) {
print(cpf.generate());
}
// This will validate a given CPF (Must be a String)
print(cpf.validate('352.753.028-27')); // -> true
// This will format a given CPF (Must be a String)
print(cpf.format('35275302827')); // -> 352.753.028-27
}
Run this command:
With Dart:
$ dart pub add cpf_util
With Flutter:
$ flutter pub add cpf_util
This will add a line like this to your package's pubspec.yaml (and run an implicit dart pub get
):
dependencies:
cpf_util: ^3.0.1
Alternatively, your editor might support dart pub get
or flutter pub get
. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:cpf_util/cpf_util.dart';
example/lib/main.dart
import 'package:cpf_util/cpf_util.dart';
void main() {
final cpfUtil = CPFUtil();
/// This will generate 100 valid CPF
for (int i = 0; i < 100; i++) {
print(cpfUtil.generate());
}
/// This will validate a given CPF (Must be a String)
print(cpfUtil.validate('352.753.028-27', state: 8)); // -> true
print(cpfUtil.validate('000.000.000-00')); // -> false
/// This will format a given CPF (Must be a String)
print(cpfUtil.format('35275302827')); // -> 352.753.028-27
}
Author: Pedrolemoz
Source Code: https://github.com/pedrolemoz/cpf_util
License: BSD-3-Clause license
1658704500
electron-util
Useful utilities for Electron apps and modules
You can use this module directly in both the main and renderer process.
This package is not compatible with Electron v12 and later.
$ npm install electron-util
Requires Electron 5 or later.
const {is} = require('electron-util');
console.log(is.macos && is.main);
//=> true
Contents
api
is
electronVersion
chromeVersion
platform()
activeWindow()
runJS()
fixPathForAsarUnpack()
enforceMacOSAppLocation()
menuBarHeight()
getWindowBoundsCentered()
centerWindow()
disableZoom()
appLaunchTimestamp
isFirstAppLaunch()
darkMode
setContentSecurityPolicy
openNewGitHubIssue()
openUrlMenuItem()
showAboutWindow()
aboutMenuItem()
debugInfo()
appMenu()
openSystemPreferences()
Type: object
Access the Electron APIs in both the main and renderer process without having to care about which one you're in.
For example, in the renderer process:
api.app.quit();
The app
API is usually only available in the main process.
Type: object
Check for various things:
macos
- Running on macOSlinux
- Running on Linuxwindows
- Running on Windowsmain
- Running on the main processrenderer
- Running on the renderer processdevelopment
- Running in development, not in productionusingAsar
- The app is using ASARmacAppStore
- The app is an Mac App Store buildwindowsStore
- The app is a Windows Store AppX buildType: string
Example: '1.7.9'
Electron version.
Type: string
Example: '62.0.3202'
Chrome version in Electron.
Type: Function
Accepts an object with the keys as either macos
, windows
, linux
, or default
, and picks the appropriate key depending on the current platform. If no platform key is matched, the default
key is used if it exists. If the value is a function, it will be executed, and the returned value will be used.
init({
enableUnicorn: util.platform({
macos: true,
windows: false,
linux: () => false
})
});
Type: Function
Returns the active window.
Type: Function
Run some JavaScript in the active or given window.
Returns a promise for the result of the executed code or a rejected promise if the result is a rejected promise.
Type: Function
ASAR is great, but it has limitations when it comes to executing binaries. For example, child_process.spawn()
is not automatically handled. So you would have to unpack the binary, for example, with the asarUnpack
option in electron-builder
. This creates a problem as the path to the binary changes, but your path.join(__dirname, 'binary')
is not changed. To make it work you need to fix the path. That's the purpose of this method.
Before:
/Users/sindresorhus/Kap.app/Contents/Resources/app.asar/node_modules/foo/binary
After:
/Users/sindresorhus/Kap.app/Contents/Resources/app.asar.unpacked/node_modules/foo/binary
Type: Function
On macOS, for security reasons, if an app is launched outside the Applications folder, it will run in a read-only disk image, which could cause subtle problems for your app. Use this method to ensure the app lives in the Applications folder.
It must not be used until the app.whenReady()
promise is resolved.
It will be a no-op during development and on other systems than macOS.
It will offer to automatically move the app for the user:
Returns the height of the menu bar on macOS, or 0
if not macOS.
Get the bounds of a window as if it was centered on the screen.
Type: object
window
Type: BrowserWindow
Default: Current window
The window to get the bounds of.
size
Type: object
Default: Size of window
Set a new window size. Example: {width: 600, height: 400}
useFullBounds
Type: boolean
Default: false
Use the full display size when calculating the position. By default, only the workable screen area is used, which excludes the Windows taskbar and macOS dock.
Center a window on the screen.
Type: object
window
Type: BrowserWindow
Default: Current window
The window to center.
size
Type: object
Default: Size of window
Set a new window size. Example: {width: 600, height: 400}
animated
Type: boolean
Default: false
Animate the change.
useFullBounds
Type: boolean
Default: false
Use the full display size when calculating the position. By default, only the workable screen area is used, which excludes the Windows taskbar and macOS dock.
Disable zooming, usually caused by pinching the trackpad on macOS or Ctrl + on Windows.
Type: BrowserWindow
Default: Current window
Type: number
A timestamp (Date.now()
) of when your app launched.
Returns a boolean
of whether it's the first time your app is launched.
It works by writing a file to app.getPath('userData')
if it doesn't exist and checks that. That means it will return true the first time you add this check to your app.
Requires Electron 7
Type: object
const {darkMode} = require('electron-util');
console.log(darkMode.isEnabled);
//=> false
darkMode.onChange(() => {
console.log(darkMode.isEnabled);
//=> true
});
Type: boolean
Whether the macOS dark mode is enabled.
On Windows and Linux, it's false
.
The callback
function is called when the macOS dark mode is toggled.
Returns a function, that when called, unsubscribes the listener.
Calling it on Window and Linux works, but it just returns a no-op function.
Set a Content Security Policy for your app.
Don't forget to validate the policy after changes.
const {setContentSecurityPolicy} = require('electron-util');
setContentSecurityPolicy(`
default-src 'none';
script-src 'self';
img-src 'self' data:;
style-src 'self';
font-src 'self';
connect-src 'self' https://api.example.com;
base-uri 'none';
form-action 'none';
frame-ancestors 'none';
`);
Type: string
You can put rules on separate lines, but lines must end in a semicolon.
Type: object
session
Type: Session
Default: electron.session.defaultSession
The session to apply the policy to.
Opens the new issue view on the given GitHub repo in the browser. Optionally, with some fields like title and body prefilled. The options are passed to the new-github-issue-url
package.
const {openNewGitHubIssue} = require('electron-util');
openNewGitHubIssue({
user: 'sindresorhus',
repo: 'playground',
body: 'Hello'
});
Accepts the same options as new MenuItem()
in addition to a url
option.
If you specify the click
option, its handler will be called before the URL is opened.
Returns a MenuItemConstructorOptions
that creates a menu item, which opens the given URL in the browser when clicked.
const {Menu} = require('electron');
const {openUrlMenuItem} = require('electron-util');
const menu = Menu.buildFromTemplate([
{
label: 'Help',
submenu: [
openUrlMenuItem({
label: 'Website',
url: 'https://sindresorhus.com'
})
]
}
]);
Menu.setApplicationMenu(menu);
Shows an 'About' window. On macOS and Linux, the native 'About' window is shown, and on Windows, a simple custom dialog is shown.
On macOS, the icon
, text
, title
, and website
options are ignored. For icon
, it already defaults to the app icon. For title
, you don't need it as the native about window doesn't have a title.
const {showAboutWindow} = require('electron-util');
showAboutWindow({
icon: path.join(__dirname, 'static/Icon.png'),
copyright: 'Copyright © Sindre Sorhus',
text: 'Some more info.'
});
Type: object
icon Linux Windows
Type: string
An absolute path to the app icon.
copyright
Type: string
The copyright text.
text
Type: string
Some additional text if needed. Shown below copyright info.
website Linux
Type: string
The URL to the app's website.
title Linux Windows
Type: string
Default: 'About'
Customizable for localization. Used in the menu item label.
The app name is automatically appended at runtime.
Accepts the same options as .showAboutWindow()
.
Returns a MenuItemConstructorOptions
that creates a menu item, which shows the about dialog when clicked.
const {Menu} = require('electron');
const {aboutMenuItem} = require('electron-util');
const menu = Menu.buildFromTemplate([
{
label: 'Help',
submenu: [
aboutMenuItem({
icon: path.join(__dirname, 'static/Icon.png'),
copyright: 'Copyright © Sindre Sorhus',
text: 'Some more info.'
})
]
}
]);
Menu.setApplicationMenu(menu);
Returns a string with debug info suitable for inclusion in bug reports.
For example, use this in the body
option of the .openNewGitHubIssue()
method.
const {debugInfo} = require('electron-util');
console.log(debugInfo());
/*
AppName 2.21.0
Electron 3.0.6
darwin 18.2.0
Locale: en-US
*/
Creating the app menu (the first menu) on macOS requires a lot of boilerplate. This method includes the default boilerplate and lets you add additional menu items in the correct place.
Type: MenuItem[]
Menu items to add below the About App Name
menu item.
Usually, you would add at least a Preferences…
menu item:
const {Menu} = require('electron');
const {appMenu} = require('electron-util');
const menu = Menu.buildFromTemplate([
appMenu([
{
label: 'Preferences…',
accelerator: 'Command+,',
click() {}
}
])
]);
Menu.setApplicationMenu(menu);
Type: Function
Open the System Preferences on macOS and Windows 10.
This method does nothing on Linux.
A list of available options can be found here.
On macOS, optionally provide a pane and section.
Type: string
Which pane of the System Preferences to open.
const {openSystemPreferences} = require('electron-util');
openSystemPreferences('security');
Type: string
Optional section within the pane.
const {openSystemPreferences} = require('electron-util');
openSystemPreferences('security', 'Firewall');
This is for non-Electron code that might be included in an Electron app. For example, if you want to add special support for Electron in a vanilla Node.js module.
const electronUtil = require('electron-util/node');
if (electronUtil.isElectron) {
// Electron workaround
} else {
// Normal code
}
Type: boolean
Check if you're running in an Electron app.
Type: string
Example: '1.7.9'
Electron version. Returns 0.0.0
when not in an Electron app.
Type: boolean
Check if the Electron app you're running in is using ASAR.
Same as the above Electron version.
Author: Sindresorhus
Source Code: https://github.com/sindresorhus/electron-util
License: MIT license
1658576640
An 'is' utility for Electron.electron-is
provides a set of isomorphic 'is' APIs, that you can use it both in main and renderer process.
See usage for more information.
$ npm install electron-is --save
is.renderer()
Returns true
if you are calling the function from the renderer process.
is.main()
Returns true
if you are calling the function from the main process.
is.macOS() aliases is.osx()
Returns true
if your app is running under Mac OS.
is.windows()
Returns true
if your app is running under Windows OS.
is.linux()
Returns true
if your app is running under Linux OS.
is.x86()
Returns true
if you the architecture of the processor is ia32
.
is.x64()
Returns true
if you the architecture of the processor is x64
.
is.production()
Returns true
if you are running the app in a production
environment.
is.dev()
Returns true
if you are running the app in a dev
environment.
is.sandbox() only macOS
Returns true
if you are running the app in a sandbox
environment under macOS.
is.mas()
Returns true
if the app is running as a Mac App Store build.
is.windowsStore()
Returns true
if the app is running as a Windows Store (appx) build.
is.all(args)
Returns true
if all the 'is functions' passed as argument are true.
example: is.all(is.osx, is.x64)
is.none(args)
Returns true
if all the 'is functions' passed as argument are false.
example: is.none(is.windows, is.x86, is.main)
is.one(args)
Returns true
if one of the 'is functions' passed as argument is true.
example: is.one(is.osx, is.linux)
is.release(args)
Checks the if the given release is the same of the OS (*)
example: is.release('10.0.10586')
is.gtRelease(args)
Checks if the given release is greater than the current OS release (*)
example: is.gtRelease('10.9.5')
is.ltRelease(args)
Checks if the given release is less than the current OS release (*)
example: is.ltRelease('6.3')
The Mac versions are mapped as osx: darwin
, you must pass the 9.x.y or 10.x.y OSX version as argument and not the darwin version.
If you are testing a Windows release you must pass the NT release, it can be x.y or x.y.build .
* Not implemented for Linux yet
// es6
import is from 'electron-is'
// es5
const is = require('electron-is')
console.log(is.main())
<script>
const is = require('electron-is')
console.log(is.renderer())
</script>
electron-is
makes use of electron-is-dev package from @sindresorhus.If you feel you can help in any way, be it with examples, extra testing, or new features please open a pull request or open an issue.
The code follows the Standard code style.
Author: Delvedor
Source Code: https://github.com/delvedor/electron-is
License: MIT license
1658023740
Thai language utility for Ruby
I have built this project in order to collect and share tools for Thai language, which are written in Ruby language.
gem install thailang4r
# encoding: UTF-8
require 'thailang4r/word_breaker'
word_breaker = ThaiLang::WordBreaker.new
puts word_breaker.break_into_words("ฉันกินข้าว")
# ["ฉัน", "กิน", "ข้าว"]
A port of royin.py transliteration from PyThaiNLP.
# encoding: UTF-8
require 'thailang4r/roman'
royin = ThaiLang::Royin.new
p royin.romanize("ฉันกินข้าว", "-")
# => "chan-kin-khao"
Author: veer66
Source Code: https://github.com/veer66/thailang4r
License: Apache-2.0 license
1654489260
dart_utils
A collection of useful helpers for Dart providing solutions for different situations.
Run this command:
With Dart:
$ dart pub add dart_utils
With Flutter:
$ flutter pub add dart_utils
This will add a line like this to your package's pubspec.yaml (and run an implicit dart pub get
):
dependencies:
dart_utils: ^2.0.0
Alternatively, your editor might support dart pub get
or flutter pub get
. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:dart_utils/dart_utils.dart';
example/dart_utils_example.dart
import 'package:dart_utils/dart_utils.dart';
main()
{
}
Please file any issues, bugs or feature request here.
Author: Jesway
Source Code: https://github.com/Jesway/Dart-Utils
License: View license
1648681200
util-linux
util-linux is a random collection of Linux utilities
Note: for the years 2006-2010 this project was named "util-linux-ng".
COMPILE & INSTALL:
See Documentation/howto-compilation.txt.
MAILING LIST:
E-MAIL: util-linux@vger.kernel.org
URL: http://vger.kernel.org/vger-lists.html#util-linux
ARCHIVE: https://lore.kernel.org/util-linux/
The mailing list will reject email messages that contain:
- more than 100K characters
- html
- spam phrases/keywords
See: http://vger.kernel.org/majordomo-info.html#taboo
IRC CHANNEL:
#util-linux at libera.chat:
irc://irc.libera.chat/util-linux
The IRC channel and Mailing list are for developers and project
maintainers. For end users it is recommended to utilize the
distribution's support system.
BUG REPORTING:
E-MAIL: util-linux@vger.kernel.org
Web: https://github.com/util-linux/util-linux/issues
Bug reports with sensitive or private information: Karel Zak <kzak@redhat.com>
This project has no resources to provide support for distribution specific
issues. For end users it is recommended to utilize the distribution's
support system.
NLS (PO TRANSLATIONS):
PO files are maintained by:
http://translationproject.org/domain/util-linux.html
VERSION SCHEMA:
Standard releases:
<major>.<minor>[.<maint>]
major = fatal and deep changes
minor = typical release with new features
maint = maintenance releases; bug fixes only
Development releases:
<major>.<minor>-rc<N>
SOURCE CODE:
Download archive:
https://www.kernel.org/pub/linux/utils/util-linux/
See also:
Documentation/howto-contribute.txt
Documentation/howto-build-sys.txt
Documentation/howto-pull-request.txt
SCM (Source Code Management) Repository:
Primary repository:
git clone git://git.kernel.org/pub/scm/utils/util-linux/util-linux.git
Backup repository:
git clone git://github.com/util-linux/util-linux.git
Web interfaces:
http://git.kernel.org/cgit/utils/util-linux/util-linux.git
https://github.com/util-linux/util-linux
Note: the GitHub repository may contain temporary development branches too.
The kernel.org repository contains master (current development) and stable/*
(maintenance) branches only. All master or stable/* changes are always pushed
to both repositories at the same time.
Repository Branches: 'git branch -a'
master branch
- current development
- the source for stable releases when deemed ready.
- day-to-day status is: 'it works for me'. This means that its
normal state is useful but not well tested.
- long-term development or invasive changes in active development are
forked into separate 'topic' branches from the tip of 'master'.
stable/ branches
- public releases
- branch name: stable/v<major>.<minor>.
- created from the 'master' branch after two or more release
candidates and the final public release. This means that the stable
releases are committed, tagged, and reachable in 'master'.
- these branches then become forked development branches. This means
that any changes made to them diverge from the 'master' branch.
- maintenance releases are part of, and belong to, their respective
stable branch. As such, they are tags(<major>.<minor>.<maint>) and
not branches of their own. They are not part of, visible in, or
have anything to do with the 'master' development branch. In git
terminology: maintenance releases are not reachable from 'master'.
- when initially cloned (as with the 'git clone' command given above)
these branches are created as 'remote tracking branches' and are
only visible by using the -a or -r options to 'git branch'. To
create a local branch use the desired tag with this command:
'git checkout -b v2.29.2 v2.29.2'
Tags: 'git tag'
- a new tag object is created for every release.
- tag name: v<version>.
- all tags are signed by the maintainer's PGP key.
Known Bugs:
- don't use tag v2.13.1 (created and published by mistake),
use v2.13.1-REAL instead.
WORKFLOW EXAMPLE:
1) development (branch: <master>)
2) master release (tags: v2.29-rc1, v2.29-rc2, v2.29, branch: <master>)
3) development (work on v2.30, branch: <master>)
4) fork -- create a new branch <stable/v2.29> based on tag v2.29
4a) new patches or cherry-pick patches from <master> (branch: <stable/v2.29>)
4b) stable release (tag: v2.29.1, branch: <stable/v2.29>)
4c) more patches; another release (tag: v2.29.2, branch: <stable/v2.29>)
5) master release v2.30 (branch: <master>)
...
where 3) and 4) happen simultaneously.
Author: util-linux
Source Code: https://github.com/util-linux/util-linux
License: GPL-2.0 License