This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# common.lib | |
# Note no #!/bin/sh as this should not spawn | |
# an extra shell. | |
STD_MSG="About to rename some files..." | |
rename() | |
{ | |
# expects to be called as: rename .txt .bak | |
FROM=$1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo -en "Please guess the magic number: " | |
read X | |
echo $X | grep "[^0-9]" > /dev/null 2>&1 | |
if [ "$?" -eq "0" ]; then | |
# If the grep found something other than 0-9 | |
# then it's not an integer. | |
echo "Sorry, wanted a number" | |
else | |
# The grep found only 0-9, so it's an integer. | |
# We can safely do a test on it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ "$X" -lt "0" ] | |
then | |
echo "X is less than zero" | |
fi | |
if [ "$X" -gt "0" ]; then | |
echo "X is more than zero" | |
fi | |
[ "$X" -le "0" ] && \ | |
echo "X is less than or equal to zero" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
@Slf4j | |
public class PersonBeanDefinitionRegistryPostProcessor | |
implements BeanDefinitionRegistryPostProcessor { | |
@Override | |
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) | |
throws BeansException { | |
// 注册Bean定义,容器根据定义返回bean | |
log.info("register personManager1>>>>>>>>>>>>>>>>"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DevLBRule extends AbstractLoadBalancerRule { | |
@Value("${some.ip.prefix}") | |
private String ipPrefix = "10.20."; | |
@Override | |
public void initWithNiwsConfig(IClientConfig iClientConfig) { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BeanFactoryPostProcessorExample { | |
public static void main (String[] args) { | |
AnnotationConfigApplicationContext context = | |
new AnnotationConfigApplicationContext(MyConfig.class); | |
MyBean bean = context.getBean(MyBean.class); | |
bean.doSomething(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BeanDefinitionBuilderExample { | |
public static void main (String[] args) { | |
DefaultListableBeanFactory beanFactory = | |
new DefaultListableBeanFactory(); | |
BeanDefinitionBuilder b = | |
BeanDefinitionBuilder.rootBeanDefinition(MyBean.class) | |
.addPropertyValue("str", "myStringValue"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GenericBeanDefinitionExample { | |
public static void main (String[] args) { | |
DefaultListableBeanFactory context = | |
new DefaultListableBeanFactory(); | |
GenericBeanDefinition gbd = new GenericBeanDefinition(); | |
gbd.setBeanClass(MyBean.class); | |
MutablePropertyValues mpv = new MutablePropertyValues(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function foo() { | |
var f = (...args) => args[0]; | |
return f(2); | |
} | |
console.log(foo()); // 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Person(){ | |
this.age = 0; | |
setInterval(() => { | |
this.age++; // |this| properly refers to the person object | |
console.log(this.age); // 1 2 3 ... | |
}, 1000); | |
} | |
var p = new Person(); |
NewerOlder