Skip to content

Instantly share code, notes, and snippets.

View Sashkan's full-sized avatar
💭
"!!". Yeah, that's a pun.

Pierre Olivier TRAN Sashkan

💭
"!!". Yeah, that's a pun.
View GitHub Profile
@Sashkan
Sashkan / settings.json
Created January 2, 2024 12:59
VSCode Settings
{
"editor.detectIndentation": false,
"files.insertFinalNewline": true,
"files.hotExit": "off",
"editor.trimAutoWhitespace": true,
"files.trimTrailingWhitespace": true,
"editor.useTabStops": true,
"keyboard.dispatch": "keyCode",
"editor.formatOnType": true, // format code as you type
"editor.formatOnSave": true, // format code when you hit save
const [amount] = process.argv.slice(2);
function getChange(given, denominations = [10, 5, 2]) {
if (!given || given === 0) {
return [];
}
let minChange = Infinity;
let minChangeArr;
for (const coin of denominations) {
const possibleCoins = [10, 5, 2];
const amount = process.argv.slice(2);
function getChange(given) {
if (!given || given === 0) {
return [];
}
let change = [];
for (const coin of possibleCoins) {
@Sashkan
Sashkan / snippets.code-snippets
Created August 7, 2020 12:23
List of usefull VSCode snippets.
{
"Print to console": {
"scope": "javascript,typescript",
"prefix": "log",
"body": [
"console.log('$1')",
"$2"
],
"description": "Log output to console"
},
@Sashkan
Sashkan / clg.code-snippets
Created November 27, 2019 15:51
Cool Snippets for anyone using React and Styled Components
{
"Print to console": {
"scope": "javascript,typescript",
"prefix": "log",
"body": [
"console.log('$1')",
"$2"
],
"description": "Log output to console"
},
@Sashkan
Sashkan / StyledButton.js
Created September 20, 2019 11:57
Syled Button Component
import React from 'react'
import { withTheme } from 'styled-components'
import StyledButton from './index.styled'
class Button extends React.Component {
render() {
try {
return (
<StyledButton {...this.props} onclick={this.props.onClick} />
@Sashkan
Sashkan / styledComponent.js
Created September 20, 2019 11:48
a simple styled component
import styled from 'styled-components'
const Wrapper = styled.div`
background-color: ${props => props.theme.backgroundColor};
`;
@Sashkan
Sashkan / themeProvider.js
Created September 20, 2019 11:41
How to wrap your App in a ThemeProvider
import { ThemeProvider } from 'styled-components'
export default function App() {
return (
<ThemeProvider theme={{ mode: 'light' }}>
<Wrapper>
Hello World
</Wrapper>
</ThemeProvider>
);
@Sashkan
Sashkan / autoScale.js
Created September 12, 2019 12:07
snap.svg autoscaling text to box
const setAutoscalingText = (text) => {
// Select text
const textObject = this.element.select(`#${clientCustomization.id}`)
if (textObject) {
// get coordinates
const textCoordinates = textObject.getBBox()
const boundingBox = this.element.select('rect').getBBox()