profile
viewpoint
David Aurelio davidaurelio Adobe Munich, Germany

davidaurelio/css-beziers 82

JavaScript tools for CSS transition timing functions (cubic bezier functions)

davidaurelio/CSS1K 2

A demonstration of what can be accomplished with only 1 K of CSS.

davidaurelio/cameradump 1

A command line camera data dumper

davidaurelio/dotfiles 1

Configuration files

davidaurelio/espresso 1

Small JavaScript VM for Arduino Mega 2560

davidaurelio/async 0

Async utilities for node and the browser

davidaurelio/ayepromise 0

A teeny-tiny promise library

davidaurelio/babel 0

:tropical_fish: Babel is a compiler for writing next generation JavaScript.

push eventdavidaurelio/dotfiles

David Aurelio

commit sha f511ab221b8d28edd38a93497db897b986255c16

[macos] Launch Agent to monitor appearance changes Adds a Launch Daemon that watches `~/Library/Preferences/.GlobalPreferences.plist`. This file is changed when the system switches appearance between Light Mode and Dark Mode. The daemon launches a bash script that will run each `.applescript` file in `~/.config/dotfiles/appearance-change/`, passing `Light` or `Dark` as command line argument. The first script changes the theme for *iTerm.* The mechanism is easy to extend to other kinds of scripts, e.g. shell scripts.

view details

push time in 11 days

push eventdavidaurelio/dotfiles

David Aurelio

commit sha 06bea856345f953223bbc452696ede1a9ba06242

[macos] Launch Agent to monitor appearance changes Adds a Launch Daemon that watches `~/Library/Preferences/.GlobalPreferences.plist`. This file is changed when the system switches appearance between Light Mode and Dark Mode. The daemon launches a bash script that will run each `.applescript` file in `~/.config/dotfiles/appearance-change/`, passing `Light` or `Dark` as command line argument. The first script changes the theme for *iTerm.* The mechanism is easy to extend to other kinds of scripts, e.g. shell scripts.

view details

push time in 11 days

issue closeddavidaurelio/hashids-python

1.3.0 release breaks 1.2.0?

I am trying to install hashids 1.2.0, which has worked for a long, long time. This currently fails under a python 3.7.7 venv. Is it possible your 1.3.0 release has affected the previous release of 1.2.0 somehow, e.g. with Flitch?

pip install hashids==1.2.0  
Collecting hashids==1.2.0
ERROR: Package 'hashids' requires a different Python: 3.7.7 not in '~=2.7,~=3.5'

https://github.com/davidaurelio/hashids-python/commit/7940cf6f3af0f3d4ebaa772a95be1bf9de9a9caf#diff-522adf759addbd3b193c74ca85243f7dR21

closed time in 12 days

mwes

issue commentdavidaurelio/hashids-python

1.3.0 release breaks 1.2.0?

I suppose we can close here.

mwes

comment created time in 12 days

issue commentdavidaurelio/hashids-python

1.3.0 release breaks 1.2.0?

@craigds done

  • released v1.3.1
  • deleted the wheel for v1.2.0 – you were right, v1.2.0 only ever had a sdist, no wheel. I set up pypi publishing via GH actions and managed to publish that today.

I will take another good look at the GH action tomorrow. I hope everybody’s setup is working for now.

mwes

comment created time in 13 days

created tagdavidaurelio/hashids-python

tagv1.3.1

Implementation of hashids (http://hashids.org) in Python. Compatible with Python 2 and Python 3

created time in 13 days

push eventdavidaurelio/hashids-python

David Aurelio

commit sha 138a12e85d09e7e76eebc1d0e059b2e28ba488e6

v1.3.1

view details

push time in 13 days

push eventdavidaurelio/hashids-python

David Aurelio

commit sha 9cbb73a4d73487108110b7a7d08dd45ace24fa56

Fix requires-python

view details

push time in 13 days

issue commentdavidaurelio/hashids-python

1.3.0 release breaks 1.2.0?

no, not enough. The metadata is set persistently on pypi :-/

mwes

comment created time in 13 days

issue commentdavidaurelio/hashids-python

1.3.0 release breaks 1.2.0?

I have yanked hashids 1.3.0 on pypi as a short term measure. I hope this will do the job. Will fix the version specifier tomorrow.

mwes

comment created time in 13 days

issue commentdavidaurelio/hashids-python

1.3.0 release breaks 1.2.0?

Seems I messed this up, apologies! I won't get to it before Monday, european time. Can you fix your version to 1.2.0 until then, please?

If anyone would like to send a PR to fix this, that'd be greatly appreciated. I will merge it tomorrow morning.

mwes

comment created time in 13 days

created tagdavidaurelio/hashids-python

tagv1.3.0

Implementation of hashids (http://hashids.org) in Python. Compatible with Python 2 and Python 3

created time in 13 days

push eventdavidaurelio/hashids-python

David Aurelio

commit sha f710babb25f143e2987177b1a8b33437af45fae5

v1.3.0

view details

push time in 13 days

delete tag davidaurelio/hashids-python

delete tag : v1.3.0

delete time in 13 days

push eventdavidaurelio/hashids-python

David Aurelio

commit sha d7a72a4a869abf6d9c4a403043d7996df9cd8173

v1.3.0

view details

push time in 13 days

created tagdavidaurelio/hashids-python

tagv1.3.0

Implementation of hashids (http://hashids.org) in Python. Compatible with Python 2 and Python 3

created time in 13 days

push eventdavidaurelio/hashids-python

David Aurelio

commit sha 48fb6704115edc44323c7f03e96a7e55af8f7e00

Update Changelog - Add all recent changes - Change format to *[Keep a Changelog],* [Keep a Changelog]: https://keepachangelog.com/en/1.0.0/

view details

push time in 13 days

delete branch davidaurelio/hashids-python

delete branch : pypi-workflow-test-only

delete time in 13 days

push eventdavidaurelio/hashids-python

David Aurelio

commit sha e0132a78499eb55a38a6ca840a0fd16a65c58ded

Workflow for publishing to PyPI Adds a github workflow to automate publishing to PyPI for tags. As a first test, each commit publishes to `test.pypi.org` only.

view details

David Aurelio

commit sha 8ef4e61eb3cd8dfab796664c59a18e2c915528fb

Merge pull request #38 from davidaurelio/pypi-workflow-test-only Workflow for publishing to PyPI

view details

push time in 13 days

PR merged davidaurelio/hashids-python

Workflow for publishing to PyPI

Adds a github workflow to automate publishing to PyPI for tags. As a first test, each commit publishes to test.pypi.org only.

+33 -0

0 comment

1 changed file

davidaurelio

pr closed time in 13 days

push eventdavidaurelio/hashids-python

David Aurelio

commit sha e0132a78499eb55a38a6ca840a0fd16a65c58ded

Workflow for publishing to PyPI Adds a github workflow to automate publishing to PyPI for tags. As a first test, each commit publishes to `test.pypi.org` only.

view details

push time in 13 days

push eventdavidaurelio/hashids-python

David Aurelio

commit sha 1acf2f58f070cea573c553e30f1d1b92e9a08244

Workflow for publishing to PyPI Adds a github workflow to automate publishing to PyPI for tags. As a first test, each commit publishes to `test.pypi.org` only.

view details

push time in 13 days

push eventdavidaurelio/hashids-python

David Aurelio

commit sha 3f020470e2640b3b1b277838f6b0ff5524d8ff2d

Workflow for publishing to PyPI Adds a github workflow to automate publishing to PyPI for tags. As a first test, each commit publishes to `test.pypi.org` only.

view details

push time in 13 days

push eventdavidaurelio/hashids-python

David Aurelio

commit sha e382239ae7047d911d86916b4433da75fb9269b0

Workflow for publishing to PyPI Adds a github workflow to automate publishing to PyPI for tags. As a first test, each commit publishes to `test.pypi.org` only.

view details

push time in 13 days

push eventdavidaurelio/hashids-python

David Aurelio

commit sha 12eaf14cb3fe9438c24282bd85308f0ceefd5705

Workflow for publishing to PyPI Adds a github workflow to automate publishing to PyPI for tags. As a first test, each commit publishes to `test.pypi.org` only.

view details

push time in 13 days

push eventdavidaurelio/hashids-python

SG5

commit sha 1a6f5907cc528c1f7d110746a496071631e2119c

add test for len_alphabet < 3

view details

David Aurelio

commit sha c2fecfff28e6cbb88607e288c4bf593b02e51ce1

Merge pull request #33 from SG5/short-alphabet-test add test for len_alphabet < 3

view details

David Aurelio

commit sha 7940cf6f3af0f3d4ebaa772a95be1bf9de9a9caf

[Build] Switch to pyproject.toml & Flit Switches to a more modern build chain. PEP [517]/[518] specify how to build a project, and how to specify dependencies. [Flitch] is a modern build tool to build *sdist* and *bdist* packages from a `pyproject.toml` Does away with `setup.py` and `MANIFEST.in`. [517]: https://www.python.org/dev/peps/pep-0517/ [518]: https://www.python.org/dev/peps/pep-0518/ [Flitch]: https://flit.readthedocs.io/

view details

David Aurelio

commit sha 479e1859c5321138dc95704c8cf6ceffda3125e1

Merge pull request #39 from davidaurelio/pyproject.toml [Build] Switch to pyproject.toml & Flit

view details

David Aurelio

commit sha 31d549278542861f0418161de50304e9715ad9a3

Workflow for publishing to PyPI Adds a github workflow to automate publishing to PyPI for tags. As a first test, each commit publishes to `test.pypi.org` only.

view details

push time in 13 days

delete branch davidaurelio/hashids-python

delete branch : pyproject.toml

delete time in 13 days

PR merged davidaurelio/hashids-python

[Build] Switch to pyproject.toml & Flit

Switches to a more modern build chain.

PEP 517/518 specify how to build a project, and how to specify dependencies. Flitch is a modern build tool to build sdist and bdist packages from a pyproject.toml

Does away with setup.py and MANIFEST.in.

+38 -31

0 comment

4 changed files

davidaurelio

pr closed time in 13 days

push eventdavidaurelio/hashids-python

David Aurelio

commit sha 7940cf6f3af0f3d4ebaa772a95be1bf9de9a9caf

[Build] Switch to pyproject.toml & Flit Switches to a more modern build chain. PEP [517]/[518] specify how to build a project, and how to specify dependencies. [Flitch] is a modern build tool to build *sdist* and *bdist* packages from a `pyproject.toml` Does away with `setup.py` and `MANIFEST.in`. [517]: https://www.python.org/dev/peps/pep-0517/ [518]: https://www.python.org/dev/peps/pep-0518/ [Flitch]: https://flit.readthedocs.io/

view details

David Aurelio

commit sha 479e1859c5321138dc95704c8cf6ceffda3125e1

Merge pull request #39 from davidaurelio/pyproject.toml [Build] Switch to pyproject.toml & Flit

view details

push time in 13 days

PR opened davidaurelio/hashids-python

[Build] Switch to pyproject.toml & Flit

Switches to a more modern build chain.

PEP 517/518 specify how to build a project, and how to specify dependencies. Flitch is a modern build tool to build sdist and bdist packages from a pyproject.toml

Does away with setup.py and MANIFEST.in.

+38 -31

0 comment

4 changed files

pr created time in 13 days

create barnchdavidaurelio/hashids-python

branch : pyproject.toml

created branch time in 13 days

PR opened davidaurelio/hashids-python

Workflow for publishing to PyPI

Adds a github workflow to automate publishing to PyPI for tags. As a first test, each commit publishes to test.pypi.org only.

+30 -0

0 comment

1 changed file

pr created time in 13 days

create barnchdavidaurelio/hashids-python

branch : pypi-workflow-test-only

created branch time in 13 days

startedodlp/bluesnooze

started time in 19 days

issue closeddavidaurelio/hashids-python

Unicode alphabets not supported?

It seems like unicode alphabets are not supported, but perhaps I am doing something wrong? e.g. the following code (Google Cloud Platform environment)...

alphabet = "😀😃😄😁😆😅😂🤣☺️😊😇🙂🙃😉😌😍😘😗😙"
hashids = Hashids(salt='test3', alphabet=alphabet)
hashid = hashids.encode(123, 456, 789)
self.response.write('<p>alphabet:' + alphabet)
self.response.write('<p>hashid:' + hashid)

I get this output (in a browser):

alphabet:😀😃😄😁😆😅😂🤣☺️😊😇🙂🙃😉😌😍😘😗😙
hashid:����↉����

(i.e. I'd expect hashid to be some combination of faces from alphabet, but they are appearing as [mostly] unknown characters.) Any possibility to add support for these funkier alphabets? Thanks!

closed time in 24 days

blukis

issue commentdavidaurelio/hashids-python

Unicode alphabets not supported?

Fair enough – I will close this issue for now. If you or anybody happen to end up needing this, I will take another look. I would assume there is existing functionality to split unicode strings these days.

blukis

comment created time in 24 days

PR merged davidaurelio/hashids-python

add test for len_alphabet < 3

code was uncovered

        if len_alphabet < 3:
            guards = separators[:num_guards]
            separators = separators[num_guards:]
+7 -0

0 comment

1 changed file

SG5

pr closed time in 25 days

pull request commentdavidaurelio/hashids-python

add test for len_alphabet < 3

Thank you!

SG5

comment created time in 25 days

push eventdavidaurelio/hashids-python

SG5

commit sha 1a6f5907cc528c1f7d110746a496071631e2119c

add test for len_alphabet < 3

view details

David Aurelio

commit sha c2fecfff28e6cbb88607e288c4bf593b02e51ce1

Merge pull request #33 from SG5/short-alphabet-test add test for len_alphabet < 3

view details

push time in 25 days

delete branch davidaurelio/hashids-python

delete branch : fix-setup

delete time in 25 days

delete branch davidaurelio/hashids-python

delete branch : compat-with-js-1.0

delete time in 25 days

delete branch davidaurelio/hashids-python

delete branch : hex

delete time in 25 days

delete branch davidaurelio/hashids-python

delete branch : update-readme

delete time in 25 days

delete branch davidaurelio/hashids-python

delete branch : fix-deprecation

delete time in 25 days

push eventdavidaurelio/hashids-python

David Aurelio

commit sha 1f8c9b387db73070fad60207c89827d4350ae615

Fix deprecation warnings When invoking `decrypt` and `encrypt` methods, deprecation warnings were displayed with the names of the wrapped functions (`decode` and `encode`). Fixes #29

view details

David Aurelio

commit sha 2dd01c532126bae28f155b24ff0732cde811c6a5

Merge pull request #37 from davidaurelio/fix-deprecation Fix deprecation warnings

view details

push time in 25 days

PR merged davidaurelio/hashids-python

Fix deprecation warnings

When invoking decrypt and encrypt methods, deprecation warnings were displayed with the names of the wrapped functions (decode and encode).

Fixes #29

+4 -4

0 comment

1 changed file

davidaurelio

pr closed time in 25 days

issue closeddavidaurelio/hashids-python

_deprecated incorrectly warns that the wrapped function will be deprecated, rather than the assigned function

These two lines should theoretically warn that encrypt and decrypt are deprecated functions. However, because they wrap the encode and decode functions, they warn that the encode and decode functions are deprecated, which is incorrect.

closed time in 25 days

tstirrat15

issue commentdavidaurelio/hashids-python

Unicode alphabets not supported?

Hi @blukis – sorry for going underground for so long. Is this still a feature you’d be interested in? Are more implementation able to handle emojis and unicode combinators these days?

There is a whole rabbit hole with unicode normalisation waiting, but maybe we can do something simple.

blukis

comment created time in 25 days

issue closeddavidaurelio/hashids-python

Array List or Tuple of integer is not supported

Seems like hashids.encode did not accept Array or Tuple argument. while the site said it could convert array of numbers like [27, 986] into “3kTMd”.

it work if hashids.encode(1,2,3), but if i pass in array like hashids.encode([1,2,3]) it will return TypeError: int() argument must be a string, a bytes-like object or a number, not 'tuple' / 'list'

this is not an issue if using hashids.js

it could be simply fix by adding another IF to check the values is list or not in line 226

Thanks!

closed time in 25 days

pohlee

issue commentdavidaurelio/hashids-python

Array List or Tuple of integer is not supported

Hi @pohlee. I am very sorry for letting you wait for over two years.

while the site said it could convert array of numbers like [27, 986] into “3kTMd”.

I am not sure whether that is mentioned anywhere for the python version.

However, you can simply unpack your tuple or list when calling like this:

hashids.encode(*[1,2,3])
pohlee

comment created time in 25 days

issue closeddavidaurelio/hashids-python

Doesn't possible to serialize Hashids-obj

Seems like it doesn't possible to serialize Hashids-obj:

from hashids import Hashids
import pickle
h = Hashids()
h
<hashids.Hashids object at 0x7faccd8097f0>
pickle.dumps(h)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
_pickle.PicklingError: Can't pickle <function Hashids.decode at 0x7faccf256e18>: it's not the same object as hashids.Hashids.decode

closed time in 25 days

vladryk

issue commentdavidaurelio/hashids-python

Doesn't possible to serialize Hashids-obj

Hi @vladryk. My apologies for not answering for over two years.

Is this still a problem for you? If yes, please open a new issue and I will look into it. Closing here for now.

vladryk

comment created time in 25 days

IssuesEvent

issue commentdavidaurelio/hashids-python

ImportError: No module named hashids

Sorry for not answering earlier.

Is this still an issue @greenstudiocorp, @dalelicious?

If yes, please provide a repro – how are you installing hashids, and which python version are you using?

Thank you!

greenstudiocorp

comment created time in 25 days

issue closeddavidaurelio/hashids-python

ImportError: No module named hashids

hashids-python is not compatible with macOS (10.13.6). Please let me know how to fix it!

closed time in 25 days

greenstudiocorp

issue closeddavidaurelio/hashids-python

Encoding ids from separate entities and avoiding collisions

Hello 👋 ! Great library @davidaurelio, thanks for putting it together :)

I have a question (a little bit conceptual). Let's say you have two entities/models (Cars and Customers, for example) and you want to generate hashids for them. What's the best way to decode a hashed id (for example xd3rpH7vEp) and realize what entity type it is? I have the following Idea:

BASE_SECRET = "AshD(/084138(/%47iasjd"
hasher = Hashids(salt=BASE_SECRET, min_length=10)

# 1 for cars
# 2 for customers
hasher.encode(1, 115)  # 'xd3rpH7vEp'

hasher.decode('xd3rpH7vEp') # (1, 115) it's a car.

Is it correct? I don't know if it could be a collision with this scheme. Thanks very much!

closed time in 25 days

santiagobasulto

issue commentdavidaurelio/hashids-python

Encoding ids from separate entities and avoiding collisions

Hi @santiagobasulto. Apologies for not answering here for almost two years.

@malefice is right – there is no support for schemas etc. You will have to something as you suggested.

About collisions – I literally haven’t looked at the code for years. I am not aware of any edge cases or collisions.

santiagobasulto

comment created time in 25 days

PR opened davidaurelio/hashids-python

Fix deprecation warnings

When invoking decrypt and encrypt methods, deprecation warnings were displayed with the names of the wrapped functions (decode and encode).

Fixes #29

+4 -4

0 comment

1 changed file

pr created time in 25 days

create barnchdavidaurelio/hashids-python

branch : fix-deprecation

created branch time in 25 days

issue commentdavidaurelio/hashids-python

_deprecated incorrectly warns that the wrapped function will be deprecated, rather than the assigned function

Thanks for reporting this, and sorry for making you wait for over a year! I will go with the simple fix.

tstirrat15

comment created time in 25 days

issue closeddavidaurelio/hashids-python

Generate hashid using string as input

Is it possible to create a short unique hashid from a string?

I need to generate a short id from uuid like 2b8b9396-0cdf-4b9c-a03d-b25e1d93601b

closed time in 25 days

fabiocaccamo

issue commentdavidaurelio/hashids-python

Generate hashid using string as input

@fabiocaccamo Sorry for never responding here. I will not add any additions that aren’t generally supported by other implementations.

Since a UUID is basically a 128bit number, you could pass it as suggested by @thedrow.

Thoughts? I will close this for now.

fabiocaccamo

comment created time in 25 days

issue commentdavidaurelio/hashids-python

How to use numbers only in alphabet

Apologies for the long silence here.

Yes, the limitation exists for compatibility with JS. I don’t have any strong opinions on that though, and if there’s interest I’d be happy to accept a PR that removes the limitation.

Thanks!

hcaihao

comment created time in 25 days

issue commentdavidaurelio/hashids-python

What is the status of this project?

Hi @malefice. Sorry for going quiet here for so long.

I willing to keep this implementation up to date, but at this point I am not using the library myself.

Hence I appreciate every kind of help that I can get.

  • Hypothesis-based tests sound awesome, and it would be great if you had some time to look into it.
  • You mentioned compat with the JS version. I can’t answer that question at this point. Are you aware of any differences?

Thanks!

malefice

comment created time in 25 days

push eventdavidaurelio/hashids-python

David Aurelio

commit sha 755fe5cfea60c4909af4e18aaccbd4ddc4b13a16

Update Readme - supported versions - compatibility table

view details

David Aurelio

commit sha 9d6974307d0ff100ed37457b03f055b0ff73b40b

Merge pull request #36 from davidaurelio/update-readme Update Readme

view details

push time in 25 days

PR merged davidaurelio/hashids-python

Update Readme
  • supported versions
  • compatibility table
+5 -5

0 comment

1 changed file

davidaurelio

pr closed time in 25 days

PR opened davidaurelio/hashids-python

Update Readme
  • supported versions
  • compatibility table
+5 -5

0 comment

1 changed file

pr created time in 25 days

create barnchdavidaurelio/hashids-python

branch : update-readme

created branch time in 25 days

delete branch davidaurelio/hashids-python

delete branch : travis/python-versions

delete time in 25 days

PR merged davidaurelio/hashids-python

[Travis] Update Python versions

Changes the list of tested Python versions to the currently active versions: 2.7, 3.5–3.8, and pypy2/3

+2 -4

0 comment

1 changed file

davidaurelio

pr closed time in 25 days

push eventdavidaurelio/hashids-python

David Aurelio

commit sha dc8c9fd51e2818a7df3fdb1c726a855988e27d37

[Travis] Update Python versions Changes the list of tested Python versions to the currently active versions: 2.7, 3.5–3.8, and pypy2/3

view details

David Aurelio

commit sha 7926c678c11d2fa2a408bfb1f467f8442ec73e09

Merge pull request #35 from davidaurelio/travis/python-versions [Travis] Update Python versions

view details

push time in 25 days

create barnchdavidaurelio/hashids-python

branch : travis/python-versions

created branch time in 25 days

PR opened davidaurelio/hashids-python

[Travis] Update Python versions

Changes the list of tested Python versions to the currently active versions: 2.7, 3.5–3.8, and pypy2/3

+2 -4

0 comment

1 changed file

pr created time in 25 days

create barnchdavidaurelio/dotfiles

branch : master

created branch time in 2 months

pull request commentfacebook/yoga

Carthage support

@SidharthGuglani could you remove me as a reviewer here? Thanks!

sjmueller

comment created time in 2 months

pull request commentfacebook/yoga

minus total outer flex basis for available width or height, when compute flex basis for children

@SidharthGuglani could you remove me as a reviewer here? Thanks!

shiyizju

comment created time in 2 months

pull request commentfacebook/yoga

Add "space-evenly" to justify-content documentation and adjusts others

@SidharthGuglani could you remove me as a reviewer here? Thanks!

MoOx

comment created time in 2 months

pull request commentfacebook/yoga

Increase that number of bit in YGStyle and YGLayout to resolve the sign issue.

I fixed this last August. However, I cannot close here since I am no longer at FB.

anyktx

comment created time in 2 months

issue commentfacebook/yoga

absolute child element percent length of left/top/right/bottom/width/height calcuated different compared with web

@SidharthGuglani could you take a look, please? Thank you!

qcclcr

comment created time in 2 months

Pull request review commentbraver/SideBarTools

[Feature] Delete and New File Commands

 def move(self, source, destination):      def description(self):         return 'Move File…'+++class SideBarDeleteCommand(sublime_plugin.WindowCommand):++    def is_visible(self):+        return self.window.active_view().file_name() is not None++    def run(self, close=False):+        file_name = self.window.active_view().file_name()+        if file_name is not None:+            self._remove(file_name)+            if close:+                # Close the active view, but no other view of the same file.+                self._close_view()++    @staticmethod+    def _remove(file_name):+        # Try using built-in functionality to send files to the trash.+        # This implementation uses the OS specific mechanism.+        try:+            from Default import send2trash+            remove = send2trash.send2trash+        except ImportError:+            import os+            remove = os.remove+        remove(file_name)++    def _close_view(self):+        view = self.window.active_view()+        # Setting to scratch prevents the save dialog from coming up.+        view.set_scratch(True)+        view.close()+++class SideBarNewFileCommand(sublime_plugin.WindowCommand):++    def is_visible(self, base):+        return base in self.window.extract_variables()++    def run(self, base):+        folders = self.window.folders()+        if base == "folder" and len(folders) != 1:+            shortened_folders = self._shorten_common_prefix(folders)+            self.window.show_quick_panel(+                shortened_folders,+                lambda idx: idx != -1 and self._name_dialog(folders[idx]))+        else:+            self._name_dialog(self.window.extract_variables()[base])++    def _name_dialog(self, folder):+        dir = folder if folder.endswith(os.path.sep) else folder + os.path.sep+        self.window.show_input_panel(+            "New File:", dir, self._new_file, None, None)++    def _new_file(self, file):+        try:+            os.makedirs(os.path.dirname(file), exist_ok=True)+            if not os.path.exists(file):+                open(file, "a").close()

In case the file does not exist, it might be nicer to use window.new_fille().retarget(file) instead of actually writing the new file immediately. Any thoughts?

davidaurelio

comment created time in 2 months

push eventdavidaurelio/SideBarTools

David Aurelio

commit sha 32f923c05ed37361f3268f35cfda8fd178480c0e

Delete and New File Commands Adds two new command implementations that are intended for use from the command palette: - `SideBarDeleteCommand` is exposed as - “File: Delete”, where the file is deleted, but the current tab remains open - “File: Delete and Close”, where the current tab is closed after deletion. Any other tabs stay open. - `SideBarNewCommand` is a command where the user enters a file name immediately, and the file is created before opening it in a tab. It comes in three version: - “File: New Relative To Current File” is enabled when the current tab has an associated file name. The folder containing the current file is used as base for the new file. - “File: New Relative To Project Root” is only enabled when within a project, and uses the directory containing the project file as base. - “File: New Relative To Base Folder” is only enabled when the side bar has at least one folder open, which will be the base directory for the new file. If the side bar shows more than one folder, the user is presented with a selection dialogue.

view details

push time in 2 months

Pull request review commentbraver/SideBarTools

[Feature] Delete and New File Commands

 def move(self, source, destination):      def description(self):         return 'Move File…'+++class SideBarDeleteCommand(sublime_plugin.WindowCommand):++    def is_visible(self):+        return self.window.active_view().file_name() is not None++    def run(self, close=False):+        file_name = self.window.active_view().file_name()+        if file_name is not None:+            self._remove(file_name)+            if close:+                # Close the active view, but no other view of the same file.+                self._close_view()++    @staticmethod+    def _remove(file_name):+        # Try using built-in functionality to send files to the trash.+        # This implementation uses the OS specific mechanism.+        try:+            from Default import send2trash+            remove = send2trash.send2trash+        except ImportError:+            import os+            remove = os.remove+        remove(file_name)++    def _close_view(self):+        view = self.window.active_view()+        # Setting to scratch prevents the save dialog from coming up.+        view.set_scratch(True)+        view.close()+++class SideBarNewFileCommand(sublime_plugin.WindowCommand):++    def is_visible(self, base):+        return base in self.window.extract_variables()++    def run(self, base):+        folders = self.window.folders()+        if base == "folder" and len(folders) != 1:+            on_done = lambda idx: idx != -1 and self._name_dialog(folders[idx])+            shortened_folders = self._shorten_common_prefix(folders)+            self.window.show_quick_panel(shortened_folders, on_done)+        else:+            self._name_dialog(self.window.extract_variables()[base])++    def _name_dialog(self, folder):+        dir = folder if folder.endswith(os.path.sep) else folder + os.path.sep+        self.window.show_input_panel(+            "New File:", dir, self._new_file, None, None)++    def _new_file(self, file):+        try:+            os.makedirs(os.path.dirname(file), exist_ok=True)+            if not os.path.exists(file):+                open(file, "a").close()+        except OSError as e:+            sublime.error_message(+                "{}:{}{}".format(e.strerror, os.linesep, e.filename))+        else:+            self.window.open_file(file)++    @staticmethod+    def _shorten_common_prefix(folders):+        prefix = os.path.commonprefix(folders).rstrip(os.path.sep)+        if prefix:+            short = "~" if prefix == os.path.expanduser("~") else "\u2026"

not sure whether the tilde as replacement for the user directory is too weird on windows. Happy to only use this on non-windows systems, or use “…” everywhere.

davidaurelio

comment created time in 2 months

PR opened braver/SideBarTools

[Feature] Delete and New File Commands

First of all, thanks for creating SideBarTools. My side bar looks much cleaner than with it, and having no tracking code in there is great.

Something I am missing is functionality to create and delete files easily from the command palette. I have implemented “File: Delete …” and “File: New Relative To …”. Check the commit message below for details.

This is not ready for merging, as at the very least the Readme will need updating. And I wanted to check whether you want these commands in your package at all, since this is not strictly side bar functionality.


Adds two new command implementations that are intended for use from the command palette:

  • SideBarDeleteCommand is exposed as

    • “File: Delete”, where the file is deleted, but the current tab remains open
    • “File: Delete and Close”, where the current tab is closed after deletion. Any other tabs stay open.
  • SideBarNewCommand is a command where the user enters a file name immediately, and the file is created before opening it in a tab. It comes in three version:

    • “File: New Relative To Current File” is enabled when the current tab has an associated file name. The folder containing the current file is used as base for the new file.
    • “File: New Relative To Project Root” is only enabled when within a project, and uses the directory containing the project file as base.
    • “File: New Relative To Base Folder” is only enabled when the side bar has at least one folder open, which will be the base directory for the new file. If the side bar shows more than one folder, the user is presented with a selection dialogue.
+96 -0

0 comment

2 changed files

pr created time in 2 months

create barnchdavidaurelio/SideBarTools

branch : palette-commands

created branch time in 2 months

fork davidaurelio/SideBarTools

Duplicate or compare files and copy paths from the Side Bar in Sublime Text 3

https://packagecontrol.io/packages/SideBarTools

fork in 2 months

delete branch davidaurelio/SideBarTools

delete branch : patch-1

delete time in 2 months

push eventdavidaurelio/dotfiles

David Aurelio

commit sha 68bb5a070528ec20c70703999cd8d64ca73b0984

[git] Worktree Helpers - `git-each-worktree` runs a command in every worktree directory of a repository - `git wtstat` runs `git status --short --branch` in every worktree

view details

push time in 2 months

push eventdavidaurelio/dotfiles

David Aurelio

commit sha 2e525a00ab24fb26e396dca16adebefa079fa044

[git] Worktree Helpers - `git-each-worktree` runs a command in every worktree directory of a repository - `git wtstat` runs `git status --short --branch` in every worktree

view details

push time in 2 months

push eventdavidaurelio/dotfiles

David Aurelio

commit sha 56404659d666e3d50ea7d6d3ff2f847c4a5f7dbd

[git] aliases: root, exec

view details

push time in 2 months

push eventdavidaurelio/dotfiles

David Aurelio

commit sha 18564dcb08d7f86b6b1666dc18d78c89331d3862

[Sublime Text] New/Delete File commands

view details

push time in 2 months

push eventdavidaurelio/dotfiles

David Aurelio

commit sha 9ef0cca1297be4be178d5c2fa02e933f72dace9d

[Alfred] Local Alfred Preferences

view details

David Aurelio

commit sha da9cf4daa3fa4820461423a0bf76a6f2d4b6c4f9

[Sublime Text] FuzzyFilePath C/C++/ObjC include trigger

view details

push time in 2 months

push eventdavidaurelio/dotfiles

David Aurelio

commit sha a092bcffcfa700976306347270255488a4deb3ad

[Alfred] Configure / add snippets - snippets not in paste history - Add emoji pack & mac symbols

view details

push time in 2 months

PR opened braver/SideBarTools

Commands: Remove duplicate entry for “move”

There were two identical command definitions for “File: Move”. This resulted in two identical entries when pressing ⌘⇧P / ⌃⇧P.

+0 -5

0 comment

1 changed file

pr created time in 2 months

push eventdavidaurelio/SideBarTools

David Aurelio

commit sha 7b2f03e3fa6c45951cc4205238621f2df5d50e83

Commands: Remove duplicate entry for “move” There were two identical command definitions for “File: Move”. This resulted in two identical entries when pressing ⌘⇧P / ⌃⇧P.

view details

push time in 2 months

fork davidaurelio/SideBarTools

Duplicate or compare files and copy paths from the Side Bar in Sublime Text 3

https://packagecontrol.io/packages/SideBarTools

fork in 2 months

push eventdavidaurelio/dotfiles

David Aurelio

commit sha 0a127524f11ad841610bdb3ba69563f5354f9715

[Sublime Text] Replace SideBarEnhancements with SideBarTools

view details

push time in 2 months

push eventdavidaurelio/dotfiles

David Aurelio

commit sha 1fb4cd3bb9e2ce1181bb5f8a274293fbe02775ed

[iTerm] Fix profile, again

view details

push time in 2 months

push eventdavidaurelio/dotfiles

David Aurelio

commit sha 4a61cb85da8f311c20b01c7b004a708e8289b7ae

[iTerm] Fix config (was crashing on startup)

view details

push time in 2 months

push eventdavidaurelio/dotfiles

David Aurelio

commit sha 582483002b553891c21ef95ad093b07db1c59ca7

[iTerm] Fix config (was crashing on startup)

view details

push time in 2 months

push eventdavidaurelio/dotfiles

David Aurelio

commit sha b4bc2aac4320d1e2f29638e7de8ee0915fe528fb

[iTerm] Fix config (was crashing on startup)

view details

push time in 2 months

more